简体   繁体   English

注意:未定义的偏移量:第14行/somepath/index.php中的1

[英]Notice: Undefined offset: 1 in /somepath/index.php on line 14

I got a problem, I get an error with this code: 我遇到了问题,此代码出现错误:

$totalpages = substr($totalpages[1],0,1);

The weird thing is, the code works? 奇怪的是,代码有效吗?

This is the error i get: 这是我得到的错误:

Notice: Undefined offset: 1 /some/spath.php on line XX</code>
if (isset($totalpages[1]))
  $totalpages = substr($totalpages[1],0,1);

BTW, you're getting a notice - not an error. 顺便说一句,您会收到通知-不是错误。 That's the reason why your code still works. 这就是您的代码仍然有效的原因。

u should check is_array($totalpages) ... 你应该检查is_array($totalpages) ...
or ini_set('error_reporting', E_ALL & ~E_NOTICE); ini_set('error_reporting', E_ALL & ~E_NOTICE);
more details on error reporting 有关错误报告的更多详细信息

before you set totalpages to whatever value you set it to, set it as a array $totalpages=array(); 在将totalpages设置为您设置的任何值之前,请将其设置为数组$totalpages=array(); OR suppress the warning $totalpages = substr(@$totalpages[1],0,1); 或禁止显示警告$totalpages = substr(@$totalpages[1],0,1);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 注意:未定义偏移量:1 in C:\\xampp\\htdocs\\index.php 第 5 行 - Notice: Undefined offset: 1 in C:\xampp\htdocs\index.php on line 5 我有错误:注意:未定义偏移量:C:\\ wamp \\ www \\ index.php在32行,34行,36行,38行的C:\\ wamp \\ www \\ index.php中 - I have error:Notice: Undefined offset: 1 in C:\wamp\www\index.php on line 32,on line 34,on line 36,on line 38 PHP公告-index.php上的未定义索引 - PHP notice - Undefined index on index.php 注意:未定义的索引:index.php中的mod - Notice: Undefined index: mod in index.php 我收到通知:未定义的偏移量:第18行的C:\\ nn \\ htdocs \\ myfiles \\ PHPCode.php中的14 - I am geting Notice: Undefined offset: 14 in C:\nn\htdocs\myfiles\PHPCode.php on line 18 注意:未定义的索引:第63行的C:\\ wamp \\ www \\ chatsystem \\ index.php中的名称 - Notice: Undefined index: name in C:\wamp\www\chatsystem\index.php on line 63 注意:未定义的索引:在第37行的C:\\ wamp \\ www \\ tests \\ Joomla \\ Website \\ index.php中 - Notice: Undefined index: in C:\wamp\www\tests\Joomla\Website\index.php on line 37 PHP注意:未定义的索引:在一行中 - PHP Notice: Undefined index: in a line 未定义的偏移量:/home/test/index.php中为7 - Undefined offset: 7 in /home/test/index.php 注意:未定义的变量:第7行的C:\\ wamp \\ www \\ cbmall \\ index.php中的db_host - Notice: Undefined variable: db_host in C:\wamp\www\cbmall\index.php on line 7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM