php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51555 Internal class reference resets the attribute
Submitted: 2010-04-14 15:59 UTC Modified: 2010-04-14 16:02 UTC
From: sinisaculic at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3SVN-2010-04-14 (snap) OS: Windows 7
Private report: No CVE-ID: None
 [2010-04-14 15:59 UTC] sinisaculic at gmail dot com
Description:
------------
I know it is uncommon usage of reference but i have  a pretty complicated 
equation 
inside a function, and i referenced a value like $a &= %this->bla...
It is easier to write $a instead $this->a... in case you have a BIG equation...

 And imagine my surprise when i saw that the value was not set... my guess is 
that 
this code somehow screws the internal references....  Searched here and nothing 
showed up for classes... just run the script it should  output the error... 
don`t 
know about UNIX OP but i doubt it is different... 
here is how i get the error:

class a {
    
   public $t;
   function buga(){
       $this->t = 'buga';
   }
   function bla(){
       
       $b &=$this->t;
       echo $b;
   }
}
$a= new a;
$a->buga();
$a->bla(); //this outputs Notice: Undefined variable: b in C:\...\test.php on 
line XX

I use Wamp Server package 2.0f latest version... Hope i was right about it... if 
not, Sorry...

With respect Siniša Čulić at sinisaculic@gmail.com

Test script:
---------------
class a {
    
   public $t;
   function buga(){
       $this->t = 'buga';
   }
   function bla(){
       
       $b &=$this->t;
       echo $b;
   }
}
$a= new a;
$a->buga();
$a->bla(); //this outputs Notice: Undefined variable: b in C:\...\test.php on line XX

Expected result:
----------------
This should output just bla

Actual result:
--------------
But it outputs a notice... and no variable...
this outputs Notice: Undefined variable: b in C:\...\test.php on line XX

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-14 16:02 UTC] rasmus@php.net
-Status: Open +Status: Bogus
 [2010-04-14 16:02 UTC] rasmus@php.net
Yes, because it should be $b = &$this->t;
 [2010-04-14 20:04 UTC] sinisaculic at gmail dot com
Ups.... mixed up C with PhP.... can someone delete this >.<`

Note to my self references and pointers are not the same PhP duos not have 
pointers....
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 22:01:31 2024 UTC