dongyou5271 2012-04-16 13:33
浏览 65

注意:未定义的偏移量:0 - 用于错误消息

I'm trying to display an error message for a required field but it is just redirecting to the page it should go to if something is entered (I'm leaving it empty)

$required_fields = array('NativeLanguage');
    foreach ($required_fields as $val) {
        while (is_array($val))
            $val = reset($val);
    if (!empty($_POST[$val])) {
        $val = trim($_POST[$val]);
    }
    else {
        $err[] = "ERROR - $val is required";
    }
    }
  • 写回答

1条回答 默认 最新

  • duanchan5458 2012-10-27 17:07
    关注

    The array vales are not set, so when PHP is trying to access the value of those array keys it encounters an undefined offset.

    $new_array = array('1','2','3');//If I have an array
    //We can now access:
    $new_array[0];
    $new_Array[1];
    $new_array[2];
    //If we try and access
    $new_Array[3];
    

    we will get the same error-->error->notice undefined offset

    评论

报告相同问题?

悬赏问题

  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答