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 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: 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

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: Sat Jun 01 11:01:33 2024 UTC