本文介紹了如何捕獲此錯誤:“注意:未定義偏移量:0"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想捕捉這個錯誤:
$a[1] = 'jfksjfks';
try {
$b = $a[0];
} catch (Exception $e) {
echo "jsdlkjflsjfkjl";
}
實際上,我在以下行中收到此錯誤:$parse = $xml->children[0]->children[0]->toArray();
in fact, I got this error on the following line:
$parse = $xml->children[0]->children[0]->toArray();
推薦答案
您需要定義您的自定義錯誤處理程序,例如:
You need to define your custom error handler like:
<?php
set_error_handler('exceptions_error_handler');
function exceptions_error_handler($severity, $message, $filename, $lineno) {
if (error_reporting() == 0) {
return;
}
if (error_reporting() & $severity) {
throw new ErrorException($message, 0, $severity, $filename, $lineno);
}
}
$a[1] = 'jfksjfks';
try {
$b = $a[0];
} catch (Exception $e) {
echo "jsdlkjflsjfkjl";
}
這篇關于如何捕獲此錯誤:“注意:未定義偏移量:0"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!