非凡首頁|軟件專題|軟件資訊|軟件發(fā)布 投訴報錯
您當(dāng)前位置: 首頁使用技巧php提示錯誤信息怎么辦?php顯示錯誤信息方法

php提示錯誤信息怎么辦?php顯示錯誤信息方法

2018-12-17 16:16:31

PHP v7.4.11

分類:服務(wù)器區(qū)星級:軟件大?。?i>51.07MB

平臺:WinXp,Win2003,WinVista,Win 7,Win 8,x64

  當(dāng)我們?yōu)g覽一些論壇時,我們經(jīng)常會遇到打開網(wǎng)頁空白的情況。實(shí)際上,它是由php在運(yùn)行過程中遇到錯誤信息引起的。如果你想知道該鏈接有問題,你必須讓php顯示錯誤信息。您可以參考以下php顯示錯誤消息方法。


  一、通過配置 php.ini 中的參數(shù)設(shè)置PHP的報錯級別

  可以在 php.ini 中適當(dāng)?shù)奈恢迷黾右恍?/p>

  error_reporting = E_ALL

  CODE: [COPY]

  error_reporting = E_ALL

  注: php.ini 中實(shí)現(xiàn)給出了一些例子,比如我本地的 php.ini 中就有如下

  ; Examples:

  ; - Show all errors, except for notices and coding standards warnings

  ;error_reporting = E_ALL & ~E_NOTICE

  ; - Show all errors, except for notices

  ;error_reporting = E_ALL & ~E_NOTICE | E_STRICT

  ; - Show only errors

  ;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR

  ; - Show all errors except for notices and coding standards warnings

  ;error_reporting = E_ALL & ~E_NOTICE

  CODE: [COPY]

  ; Examples:

  ; - Show all errors, except for notices and coding standards warnings

  ;error_reporting = E_ALL & ~E_NOTICE

  ; - Show all errors, except for notices

  ;error_reporting = E_ALL & ~E_NOTICE | E_STRICT

  ; - Show only errors

  ;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR

  ; - Show all errors except for notices and coding standards warnings

  ;error_reporting = E_ALL & ~E_NOTICE

  我只要在這些行代碼的下面增加 error_reporting = E_ALL 然后重新啟動 web 服務(wù)就可以了

  二、通過 PHP 函數(shù) error_reporting 設(shè)定 PHP 報錯級別

  如果你無權(quán)修改 php.ini 中的參數(shù)配置,你可以通過這個函數(shù)來設(shè)置報錯級別。

  error_reporting() 函數(shù)使用方法

  error_reporting(report_level)

  如果參數(shù) level 未指定,當(dāng)前報錯級別將被返回。

  任意數(shù)目的以上選項(xiàng)都可以用“或”來連接(用 OR 或 |),這樣可以報告所有需要的各級別錯誤。例如,下面的代碼關(guān)閉了用戶自定義的錯誤和警告,執(zhí)行了某些操作,然后恢復(fù)到原始的報錯級別:

  //禁用錯誤報告

  error_reporting(0);

  //報告運(yùn)行時錯誤

  error_reporting(E_ERROR | E_WARNING | E_PARSE);

  //報告所有錯誤

  error_reporting(E_ALL);

  CODE: [COPY]

  //禁用錯誤報告

  error_reporting(0);

  //報告運(yùn)行時錯誤

  error_reporting(E_ERROR | E_WARNING | E_PARSE);

  //報告所有錯誤

  error_reporting(E_ALL);

  那么我們就可以把論壇里的 include/common.inc.php文件里的

  error_reporting(0);

  CODE: [COPY]

  error_reporting(0);

  修改成

  error_reporting(E_ALL);

  CODE: [COPY]

  error_reporting(E_ALL);

  然后保存,這樣就可以看到 PHP 報告的錯誤信息了


国产精品秘 久久久囯产,亚洲无码在线网站,亚洲欧美日韩综合专区,亚洲A∨无码精品午夜在线观看