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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dietmar dot kling at sam-net dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 02:01:35 2025 UTC