本文 8975 pv

1

Php 中全局变量在函数中使用时必须申明为全局

© kekehu / 技术资源 / 2006.05.03 / 12:56 / 8975PV

PHP 中全局变量在函数中使用时必须申明为全局。例如:

<?php
$a = 1;
$b = 2;
function Sum()
{
   global $a, $b;

   $b = $a + $b;
}

Sum();
echo $b;
?>

本文有 1 篇评论

发表你的见解

打开HTML 打开UBB 打开表情 隐藏 记住我
emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot
emotemotemotemotemot