php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28443 Var is changed without a reason
Submitted: 2004-05-19 09:28 UTC Modified: 2004-05-19 09:32 UTC
From: nitz at framingo dot de Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.6 OS: Win2k
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nitz at framingo dot de
New email:
PHP Version: OS:

 

 [2004-05-19 09:28 UTC] nitz at framingo dot de
Description:
------------
Class constructor sets a var to a value that is only assigned to an other var.


Reproduce code:
---------------
<?php
class FG_Timestamp{
	var $timestamp;
	var $limit;

	function FG_Timestamp($ts=-1)
	{
		$this->$timestamp=0;
		$this->$limit=1; 
		echo "1 val limit=".$this->$limit."<br>";
		if ($ts<0)
			$this->$timestamp=time();
		else
		 $this->$timestamp=2;
		echo "2 val limit=".$this->$limit."<br>";
	}
}
$cmp=new FG_Timestamp(0);
?>

Expected result:
----------------
1 val limit=1
2 val limit=1 

Actual result:
--------------
1 val limit=1
2 val limit=2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-19 09:32 UTC] alan_k@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

$this->$limit
$this->limit

you are using variable properties.. - effetcively setting $this->{\'\'}

try running with error_reporting(E_ALL);
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Dec 04 20:03:34 2021 UTC