PHP比较字符串错误

阿比

我是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===strcmpin,if但仍然是同一问题。

阿比

引起问题是因为我没有意识到我已经比较了args>2。使它> = 2并完成了中提琴!!感谢@barmar指出这一点!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章