php Notice: Undefined variable
<html><head><title>text</title></head><body><?phpfunctionfun(){$Num=func_num_args();$...
<html>
<head>
<title>text</title>
</head>
<body>
<?php
function fun()
{
$Num=func_num_args();
$List=func_get_args();
$Result;
for($i=$Num-1;$i>=0;$i--)
$Result.=$List[$i];
return $Result;
}
$Var1=fun(1,2,3,4);
$Var2=fun("t","n","e","d","u","t","s");
echo "$Var1<br/>";
echo "$Var2<br/>";
?>
----------------------------------------------------------------------------
页面显示》
Notice: Undefined variable: Result in D:\wamp\www\index.php on line 14
Notice: Undefined variable: Result in D:\wamp\www\index.php on line 14
4321
student
----------------------------------------------------------------------------
为什么会多出2个Notice,问题出在哪里 展开
<head>
<title>text</title>
</head>
<body>
<?php
function fun()
{
$Num=func_num_args();
$List=func_get_args();
$Result;
for($i=$Num-1;$i>=0;$i--)
$Result.=$List[$i];
return $Result;
}
$Var1=fun(1,2,3,4);
$Var2=fun("t","n","e","d","u","t","s");
echo "$Var1<br/>";
echo "$Var2<br/>";
?>
----------------------------------------------------------------------------
页面显示》
Notice: Undefined variable: Result in D:\wamp\www\index.php on line 14
Notice: Undefined variable: Result in D:\wamp\www\index.php on line 14
4321
student
----------------------------------------------------------------------------
为什么会多出2个Notice,问题出在哪里 展开
2个回答
展开全部
<html>
<head>
<title>text</title>
</head>
<body>
<?php
function fun()
{
$Num=func_num_args();
$List=func_get_args();
$Result=0;
for($i=$Num-1;$i>=0;$i--)
$Result.=$List[$i];
return $Result;
}
$Var1=fun(1,2,3,4);
$Var2=fun("t","n","e","d","u","t","s");
echo "$Var1<br/>";
echo "$Var2<br/>";
?>
因为函数被调用了两次,错误的原因是$result没声明;
<head>
<title>text</title>
</head>
<body>
<?php
function fun()
{
$Num=func_num_args();
$List=func_get_args();
$Result=0;
for($i=$Num-1;$i>=0;$i--)
$Result.=$List[$i];
return $Result;
}
$Var1=fun(1,2,3,4);
$Var2=fun("t","n","e","d","u","t","s");
echo "$Var1<br/>";
echo "$Var2<br/>";
?>
因为函数被调用了两次,错误的原因是$result没声明;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询