php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16612 Function called from class treats GLOBAL vars in different way...
Submitted: 2002-04-15 05:39 UTC Modified: 2002-04-15 19:49 UTC
From: daniel at webdevelopers dot cz Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.1.2 OS: Windows 2000, Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: daniel at webdevelopers dot cz
New email:
PHP Version: OS:

 

 [2002-04-15 05:39 UTC] daniel at webdevelopers dot cz
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;
	if (is_object($ref)) {
		$GLOBALS["obj"]=&$ref; # This is the same as '$obj=&$ref;'. Isn't it?
		#* $obj=&$ref;
	}
}

#===========================================================
$test=new test();
var_dump($obj);

?>
</PRE>
--- SCRIPT: END ---

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-15 06:27 UTC] daniel at webdevelopers dot cz
Duplicate submission. Sorry.
 [2002-04-15 19:49 UTC] sniper@php.net
Please do not submit the same bug more than once.


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