在PHP中error_reporting這個函數有什麼作用?

來源:互聯網
上載者:User

標籤:ons   設定   man   parse   fse   param   reporting   http   errors   

答:error_reporting() 設定 PHP 的報錯層級並返回當前層級。

error_reporting() — 設定應該報告何種 PHP 錯誤

int error_reporting ([ int $level ] )

error_reporting() 函數能夠在運行時設定 error_reporting 指令。 PHP 有諸多錯誤層級,使用該函數可以設定在指令碼運行時的層級。 如果沒有設定選擇性參數 level, error_reporting() 僅會返回當前的錯誤報表層級。

參數

level:新的 error_reporting 層級。 可以是一個位元遮罩也可以是一個已命名的常量。 強烈建議使用已命名的常量,以確保相容將來的版本。 由於錯誤層級的添加、整數取值範圍的增加, 較久的基於整數的錯誤層級不會總是和預期的表現一致。

可用的錯誤層級常量及其實際含義描述在了 predefined constants 中。

傳回值 返回舊的 error_reporting 層級,或者在 level 參數未給出時返回當前的層級。

 

<?php// 關閉所有PHP錯誤報表error_reporting(0);// Report simple running errorserror_reporting(E_ERROR | E_WARNING | E_PARSE);// 報告 E_NOTICE也挺好 (報告未初始化的變數// 或者捕獲變數名的錯誤拼字)error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);// 除了 E_NOTICE,報告其他所有錯誤// 這是在 php.ini 裡的預設設定error_reporting(E_ALL ^ E_NOTICE);// 報告所有 PHP 錯誤 (參見 changelog)error_reporting(E_ALL);// 報告所有 PHP 錯誤error_reporting(-1);// 和 error_reporting(E_ALL); 一樣ini_set(‘error_reporting‘, E_ALL);?>

http://php.net/manual/zh/function.error-reporting.php

 

在PHP中error_reporting這個函數有什麼作用?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.