Page 1 of 1

global variables

Posted: Mon Apr 28, 2003 1:34 pm
by kendall
Hello,

i have in an included file of a main file, a function that has

if($info){
global $info;
return true;
}

in the main file have a echo $info;

Now i know the info has data as test have proven so. But for some reason its not echoing $info how does the global $info affected in included files?

Posted: Mon Apr 28, 2003 2:37 pm
by volka
your switching to the global scope too late

Code: Select all

<?php
function test()
{
	$i = 0; // setting test::$i
	global $i; // setting the scope of $i to global
	// the local test::$i is lost
}
?>