php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25167 Variable get overwritten inside class
Submitted: 2003-08-20 02:59 UTC Modified: 2003-08-20 03:19 UTC
From: bakkerl at lamp dot xs4all dot nl Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.2 OS: RedHat 9
Private report: No CVE-ID: None
 [2003-08-20 02:59 UTC] bakkerl at lamp dot xs4all dot nl
Description:
------------
A class which contains more than 1 variable, all varible gets the same values. The all get the value of the last value assinging.

Reproduce code:
---------------
<?php
class test
{
  var $a;
  var $b;
  function test()
  {
    $this->$a = "Hello";
    $this->$b = "World!";
  }
  function showWorld()
  {
  	echo $this->$a." ".$this->$b;
  }
}
?>

Expected result:
----------------
After calling showWorld() i would expect to see:
"Hello World!".




Actual result:
--------------
After calling showWorld() i got:
"World! World!"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-20 03:19 UTC] sniper@php.net
If your script didn't have all those errors, it would work just fine..(hint: $this->a)

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 15:01:32 2024 UTC