Bug #16613: Function called from class treats GLOBAL vars in different way...
| From: | daniel at webdevelopers dot cz | Date: | Mon, 15 Apr 2002 09:53:38 +0000 |
| Subject: | Bug #16613: Function called from class treats GLOBAL vars in different way... | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-5009@lists.php.net to get a copy of this message | ||
From: daniel@webdevelopers.cz
Operating system: Windows 2000, Windows XP
PHP version: 4.1.2
PHP Bug Type: Class/Object related
Bug description: Function called from class treats GLOBAL vars in different way...
There is the line marked with '#*' in the following script. One line up you
will find other line that should make the exactly same action (I think).
Try to comment this line and uncomment line with '#*'. The output will
differ. Why?
--- SCRIPT: START ---
<PRE><?php
class test {
function test() {
extfunc($this);
}
}
#__________________________________________________________________________________________________
function extfunc(&$ref) {
global $obj;
$GLOBALS["obj"]=&$ref; # This is the same as '$obj=&$ref;'. Isn't
it?
#* $obj=&$ref;
}
#===========================================================
$test=new test();
var_dump($obj);
?></PRE>
--- SCRIPT: END ---
--
Edit bug report at http://bugs.php.net/?id=16613&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=16613&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=16613&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=16613&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=16613&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16613&r=support
Expected behavior: http://bugs.php.net/fix.php?id=16613&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=16613&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=16613&r=submittedtwice