I have problem to Global Variables inside functions
<?php
function main(){
$var = "My Variable";
function sub() {
GLOBAL $var;
echo $var; // Will show "My Variable"
}
sub();
echo $var; // Will show "My Variable"
}
main();
sub(); // Will not show and I will sub() cant use outside main() function
?>
- I just want to global
$var
inside sub functions -
sub()
will not work outsidemain()
function
I tied to use GLOBAL
but it show nothing ... Any ?