`
阿尔萨斯
  • 浏览: 4200491 次
社区版块
存档分类
最新评论

Notice: Undefined offset的问题

 
阅读更多
今天遇到了这样一个问题

Notice: Undefined offset: 20 in D:/AppServ/www/newcoop/auto_check_date.php on line 36

相信有很多刚学习PHP的人也遇到 Notice: Undefined offset: .....这类问题,因为在网上
随便一搜就一大堆.这问题很常出现在数组中的,程序是能正确地运行下去,但是在屏幕上总会出现这样的提示:Notice: Undefined offset: ..... 网上普遍是采用抑制其显示的方法,即更改php.ini文件中error_repoting的参数为"EALL & Notice ",这样屏幕就能正常显示了.

问题是解决了,但是总想不透offset:接下去的数字(如 Notice: Undefined offset: 4 ....)是什么意思.还有,句子里的语法明明是正确的,为什么会出现警告.冷静地思考了好几遍并尝试了每种可能,终于找到了答案.offset:接下去的数字是出错的数组下标,一般是超出了数组的取值范围,如定义了数组$A[]有10个元数,如果出现了$A[10]就会出现错误(Notice: Undefined offset: 10 ....),因为数组的下标是从0开始的,所以这个数组的下标就只能是0~9.因此在出现这类问题时,不要急于用抑制显示的方法(更简单的可以在当前文件的最前面加上一句"error_reporting(填offset:接下去的那个数字);,一定要注意你所用的数组下标,仔细思考一下,问题一定会很快得到解决的 !
分享到:
评论

相关推荐

    PHP提示Notice: Undefined variable的解决办法

    Notice: Undefined variable 这就是将警告在页面上打印出来,虽然这是有利于暴露问题,但实现使用中会存在很多问题。 需要设置显示错误级别,来解决问题。 网络上的通用解决办法是修改php.ini的配置: 解决方法: 1)...

    php Notice: Undefined index 错误提示解决方法

    字面意思就是未定义的索引,一般情况下是因为程序开发作者判断不严谨导致。一般不会影响程序的运行,具体的解决方法可以参考下。

    PHP运行出现Notice : Use of undefined constant 的完美解决方案分享

    Notice: Use of undefined constant ALL_PS – assumed ‘ALL_PS’ in E:\Server\vhosts\www.lvtao.net\global.php on line 50 Notice: Undefined index: EaseTemplateVer in E:\Server\vhosts\...

    Notice: Undefined index: page in E:\PHP\test.php on line 14

    Notice: Undefined index: page in E:PHPtest.php on line 14

    PHP新手NOTICE错误常见解决方法

    页面中,好多类似 Notice: Use of undefined constant title – assumed ‘title’ in D:\wamp\www\phpmysqlweb\bbs\list.php on line 17 页面很难看,很纠结啊,我用的是wamp集成包。 百度了下,看来好多朋友也有...

    php Undefined index的问题

    又是一个提交程序的小bug,以前写程序的时候对提交数据几乎没做什么验证判断,比如接受 tj 的值,根本就没有定义数据类型就直接进行提交了,所以导至了 Notice: Undefined index: tj in //index.php on line 67 这样...

    php Undefined index和Undefined variable的解决方法

    $act $ POST["act"]; 用以上代码总是提示 Notice: Undefined index: act in F: windsflybook post php on line 18 另外 有时还会出现 引用内容 Notice: Undefined variable: Submit

    万年历的代码

    <!DOCTYPE ...<... <head> <... charset=utf-8" /> ... <div id='festival_detail_str'>1月22日至1月28日放假7天,1月21日(星期六)、1月29日(星期日)上班。...

    PHP 中提示undefined index如何解决(多种方法)

    平时用$_post[”]或$_get[”]获取表单中参数时会出现Notice: Undefined index: ——–; 以及我们经常接收表单POST过来的数据时报Undefined index错误 例如:$act=$_POST[‘action’];使用以上代码总是会提示Notice: ...

    php提示undefined index的几种解决方法

    平时用$_post[”],$_get[”]获取表单中参数时会出现Notice: Undefined index: ——–; 我们经常接收表单POST过来的数据时报Undefined index错误,如下: $act=$_POST[‘action’]; 用以上代码总是提示 Notice: ...

    PHP函数之error_reporting(E_ALL ^ E_NOTICE)详细说明

    } 在4.3.0中运行正常,在4.3.1中运行会提示Notice:Undefined varialbe:tmp_i 问题下下: 1.问题出在哪里? 2.应如何修改这段代码? 3.不改段代码,如何修改php.ini中的设置使原来在4.3.0中的程序在4.3.1的环境下...

    Notice: Trying to get property of non-object problem(PHP)解决办法

    今天又一次遇到PHP 的一个提醒:Notice: Trying to get property of non-object problem,这种错误很常见

    屏蔽PHP默认设置中的Notice警告的方法

    PHP Notice: Undefined variable PHP Notice: Undefined index 看看吧,你有没定义的变量直接使用了。不过编PHP的时候本来就不像C++那么严格,编程的时候经常还会利用这个特点。PHP的默认设置是显示这些提示,这会...

    webstar php留言板 v4.6.rar

    关于留言本的使用方法和... 1、主要解决了大家经常跟我提出的页面出现“Notice: Undefined variable...”的问题  2、更改了部分文件的位置和内容,以减少新手们的学习成本和代码的简洁性  3、修正了部分错误链接

    安装lamp报错信息及解决方法

    Notice: Following unknown configure options were used: usr/bin/ld: cannot find -lltdl /usr/bin/ld: cannot find -lmysqlclient httpd: Syntax error on line 57 of /etc/httpd/httpd.conf: Cannot load /usr/...

Global site tag (gtag.js) - Google Analytics