$GLOBALS 添加超全局变量

<?php
function test() {
    $foo = "local variable";

    echo '$foo in global scope: ' . $GLOBALS["foo"] . "
";
    echo '$foo in current scope: ' . $foo . "
";
}

$foo = "Example content";
test();
?>


结果:

$foo in global scope: Example content
$foo in current scope: local variable
 

$GLOBAL["变量名"];

原文地址:https://www.cnblogs.com/Fadinglemon/p/3828958.html