在函数外定义的全局变量。在函数中无法直接使用,需要使用 global
<?php
$a = 1;
$b = 2;
function test(){
global $a, $b;
print_r($a+$b); // 3
}
test();
?>
在函数外定义的全局变量。在函数中无法直接使用,需要使用 global
<?php
$a = 1;
$b = 2;
function test(){
global $a, $b;
print_r($a+$b); // 3
}
test();
?>