我是PHP的初学者,我正在尝试根据参数分隔输入。以下是我的代码,但似乎$arg
从未设置我的变量。有人可以指出我的错误吗?
$sender = $_GET['sender'];
$receiver = $_GET['receiver'];
$message = $_GET['message'];
$temp = explode( '.', $message);
$tempcnt = count($temp);
echo $temp[$tempcnt - 1];
if($tempcnt > 2)
{
if($temp[$tempcnt-1] === 'mp4')
{$arg = 3;}
elseif($temp[$tempcnt-1]==='jpg')
{$arg = 2;}
else
{$arg = 1;}
}
echo "Value of arg is" . $arg;
我什至尝试过==
and===
和strcmp
in,if
但仍然是同一问题。
引起问题是因为我没有意识到我已经比较了args>2。使它> = 2并完成了中提琴!!感谢@barmar指出这一点!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句