PHP中出现Notice: Undefined variable: number1 in D:\Wampserver2\www\3-10.php on line9 的问题
<html><head><title>3-10</title></head><body><?php$number1=20;functionlocal()//自订local...
<html>
<head><title>3-10</title>
</head>
<body>
<?php
$number1 = 20;
function local() //自订local函数
{
$number2 = 30;
echo "函数中\$number1 = $number1";
echo "<BR>";
echo "函数中\$number2 = $number2";
echo "<BR>";
}
local(); //自订local函数
echo "函数中\$number1 = $number1";
echo "<BR>";
echo "函数中\$number2 = $number2";
?>
</body>
</html>
怎么通过加句段改过来 展开
<head><title>3-10</title>
</head>
<body>
<?php
$number1 = 20;
function local() //自订local函数
{
$number2 = 30;
echo "函数中\$number1 = $number1";
echo "<BR>";
echo "函数中\$number2 = $number2";
echo "<BR>";
}
local(); //自订local函数
echo "函数中\$number1 = $number1";
echo "<BR>";
echo "函数中\$number2 = $number2";
?>
</body>
</html>
怎么通过加句段改过来 展开
1个回答
展开全部
<html>
<head><title>3-10</title>
</head>
<body>
<?php
$number1 = 20;
function local() //自订local函数
{
global $number1,$number2;
$number2 = 30;
echo "函数中$number1 = $number1";
echo "<BR>";
echo "函数中\$number2 = $number2";
echo "<BR>";
return $number2;
}
local(); //自订local函数
echo "函数中\$number1 = $number1";
echo "<BR>";
echo "函数中\$number2 = $number2";
?>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询