0
Why php global declared varible cant be used inside the function?
As the question mention it seems kinda wierd. In most programming language I learn so far, global variable can be used from anywhere. So why doesn't php support this?
3 ответов
+ 1
For this the $GLOBALS[] is used.
For usage please read in the PHP manual:
http://php.net/manual/en/reserved.variables.globals.php
+ 1
$GLOBALS['VariableName'] used to access global variables from anywhere .
Example :
$name = 'Zardi' ;
function msg()
{
echo "Name : ".$GLOBALS['name'];
}
msg(); // Name : Zardi
0
thanks manuel