主页
PHP
PHP 变量作用域
tryphp_var_global
运行 ❯
×
更改方向
保存代码
更改主题
<?php $x = 5; // global scope function myTest() { // using x inside this function will generate an error echo "
Variable x inside function is: $x
"; } myTest(); echo "
Variable x outside function is: $x
"; ?>
函数内部的变量 x 是
函数外部的变量 x 是:5