php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16207 var referencing doesnt work on global vars?
Submitted: 2002-03-21 12:57 UTC Modified: 2002-03-21 13:01 UTC
From: vedad at kajtaz dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.1.2 OS: linux 2.2.20
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: vedad at kajtaz dot net
New email:
PHP Version: OS:

 

 [2002-03-21 12:57 UTC] vedad at kajtaz dot net
Hello,

Using references from and to global vars inside a function doesnt seem to work. 

Try this out:
---->8----->8----->8----->8-
<?
function	SomeFunction()
{
	global	$a, $b, $c;

	$d = array(1, 2, 3);

	$a = $d;
	$b = &$a;
	$c = &$a;
}

SomeFunction();

?><pre>a:<br><?print_r($a)?></pre><hr><?
?><pre>b:<br><?print_r($b)?></pre><hr><?
?><pre>c:<br><?print_r($c)?></pre><hr><?

// end
?>
---->8----->8----->8----->8-

Logically, $b and $c should be references to $a, but they seem to be empty vars!

Thanks,
-- vedad

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-21 13:01 UTC] mfischer@php.net
That's a limitation of the engine. 'global'ized variables inside function are in fact references to the global variable.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 12 00:01:27 2024 UTC