php錯誤顯示

爲啥要整理下php的報錯機制?php

一門語言懂了報錯機制,就能夠處理複雜的異常或錯誤代碼了。提升功力web

 

設置php錯誤顯示等級ui

ini_set('display_errors', 1);
#

 

 

實力調試出錯誤spa

Warning 調試

警告code

Warning: Invalid argument supplied for foreach() in /data/www/sf-plearnu-local/web/3.php on line 9io

ini_set('display_errors', 1);

foreach(1 as $v); 程序編譯後。執行出錯,報警告錯誤

 

Parse編譯

解析class

 

Parse error: syntax error, unexpected end of file in /data/www/sf-plearnu-local/web/3.php on line 10require

ini_set('display_errors', 1);

foreach(1 as $v)

// 少了標點符號,在解析代碼的時候就錯誤了

 

Notice

通知

 

Notice: Undefined variable: ads in /data/www/sf-plearnu-local/web/3.php on line 9

ini_set('display_errors', 1);

echo $ads;

// 變量未定義,通知錯誤

 

Fatal

致命

 

它話

include 包含的文件不存在的時候,程序報警告錯誤。代碼繼續執行

require 包含的文件不存在的時候,程序報致命錯誤,代碼不向下執行

require('321.php');
echo '---';

Warning: require(321.php): failed to open stream: No such file or directory in /data/www/sf-plearnu-local/web/1.php on line 10

Fatal error: require(): Failed opening required '321.php' (include_path='.:/usr/share/pear:/usr/share/php') in /data/www/sf-plearnu-local/web/1.php on line 10
include('321.php');
echo '---';

Warning: include(321.php): failed to open stream: No such file or directory in /data/www/sf-plearnu-local/web/1.php on line 10

Warning: include(): Failed opening '321.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /data/www/sf-plearnu-local/web/1.php on line 10
---
相關文章
相關標籤/搜索