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
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: bakkerl at lamp dot xs4all dot nl
New email:
PHP Version: OS:

 

 [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-2025 The PHP Group
All rights reserved.
Last updated: Mon May 12 09:01:27 2025 UTC