[英]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.