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
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC