doulongdan2264 2018-04-16 06: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-16 06: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;
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 学不会递归,理解不了汉诺塔参数变化
  • ¥30 软件自定义无线电该怎样使用
  • ¥15 R语言mediation包做中介分析,直接效应和间接效应都很小,为什么?
  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)