doulongdan2264 2018-04-15 22:49
浏览 49
已采纳

更新后Xampp中的致命错误:无法使用isset()

When I open old project in Xampp I have trouble with isset code. Actually its happening since I updated my Xampp from 1.7.3 to 3.2.1 xampp. Looks like the error is in this line:

for ($i = 1; $i <= CITY_COUNT; $i++) {
    for ($j = 1; $j <= CITY_COUNT; $j++) {
        if (isset(@$_POST[$i . '_' . $j]))
            //
            $distances[$i][$j] = @$_POST[$i . '_' . $j];
        else if (isset(@$_POST[$j . '_' . $i]))
            $distances[$i][$j] = @$_POST[$j . '_' . $i];
        else
            $distances[$i][$j] = 32767;
    }
}

I am getting an fatal error. The error say " Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) " But I don't know what's wrong in that code.. in old xampp 1.7.3 I didn't saw that error.

Please guide me.

  • 写回答

1条回答 默认 最新

  • dongyata3336 2018-04-15 22:55
    关注

    Just remove isset where you are using $_POST. This will automatically check if the value is there else you have settled default value.

    Updated

    As per @magnus idea, remove @ before $_POST.

    for ($i = 1; $i <= CITY_COUNT; $i++) {
        for ($j = 1; $j <= CITY_COUNT; $j++) {
            if ($_POST[$i . '_' . $j] != '')
                //
                $distances[$i][$j] = $_POST[$i . '_' . $j];
            else if ($_POST[$j . '_' . $i] != '')
                $distances[$i][$j] = $_POST[$j . '_' . $i];
            else
                $distances[$i][$j] = 32767;
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部