时间:2021-07-01 10:21:17 帮助过:37人阅读
<?php
$str = "string";
function test()
{
if (isset($str))
{
echo "the string is defined";
}
else
{
echo "the string is undefined";
}
}
test();
?>这是在浏览器中的运行结果:

<?php
$str = "string";
function test()
{
global $str;//上面的test函数中没有这句话
if (isset($str))
{
echo "the string is defined";
}
else
{
echo "the string is undefined";
}
}
test();
?>这是在浏览器中的运行结果:

以上就是php 中global关键字的使用 的详细内容,更多请关注Gxl网其它相关文章!