It works, but the scope of test2() limited. For example, this works:
[ wally@zf ~]$ cat y.php <?php function test1 () { global $x; $x=123; function test2() { global $x; echo $x; } test2(); } test1(); ?> [ wally@zf ~]$ php -f y.php 123[ wally@zf ~]$
source share