php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5490 class variables get mixed up
Submitted: 2000-07-10 06:05 UTC Modified: 2000-07-10 06:09 UTC
From: dietmar dot kling at sam-net dot de Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.1pl2 OS: linux 2.2.16
Private report: No CVE-ID: None
 [2000-07-10 06:05 UTC] dietmar dot kling at sam-net dot de
<?php

class bugtest
{
  var $A = -1;
  var $B = -1;

	function setVarA($value)
	{
    $this->$A=$value;
	}
	function setVarB($value)
	{
    $this->$B=$value;
	}

	function getVarA()
	{
    return $this->$A;
	}

  function getVarB()
	{
    return $this->$B;
	}

}
 echo "<BR>";
  echo "Current PHP version: ".phpversion();
  $bug = new bugtest;
	$bug->setVarA(13);
	$bug->setVarB(7);
	echo "<BR>";
	echo $bug->getVarA();
	echo "<BR>";
	echo $bug->getVarB();

?>


This is the output !! ( Where has "13" gone???")


Current PHP version: 4.0.1pl2
7
7


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-10 06:09 UTC] stas at cvs dot php dot net
Syntax is $object->var, not $object->$var.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 21:01:33 2024 UTC