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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Mar 01 19:01:33 2024 UTC