error_reporting

(PHP 3, PHP 4 , PHP 5)

error_reporting -- definisce quali errori di PHP vengono restituiti

Description

int error_reporting ( [int livello])

Definisce il livello di restituzione di errore di PHP e ritorna il vecchio livello. Il livello di restituzione dell'errore può essere una maschera di bit o una costante named. L'utilizzo delle costanti named è caldamente consigliato per assicurare la compatibilità con versioni future. All'aggiungere di livelli di errore, la gamma degli interi viene incrementata, perciò vecchi livelli di errore basati sull'intero non si comporteranno sempre come ci si aspetta.

Esempio 1. Error Integer changes

error_reporting (55);   // Equivalente a E_ALL ^ E_NOTICE in PHP 3

/* ...in PHP 4, '55' indica (E_ERROR | E_WARNING | E_PARSE |
E_CORE_ERROR | E_CORE_WARNING) */

error_reporting (2039); // Equivalente a E_ALL ^ E_NOTICE in PHP 4

error_reporting (E_ALL ^ E_NOTICE); // Il medesimo in PHP 3 e 4
Seguite i collegamenti delle costanti per conoscerne il significato:

Tabella 1. error_reporting() valori dei bit

valorecostante
1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING
64 E_COMPILE_ERROR
128 E_COMPILE_WARNING
256 E_USER_ERROR
512 E_USER_WARNING
1024 E_USER_NOTICE
2047 E_ALL

Esempio 2. esempi error_reporting()

// Turn off all error reporting
error_reporting (0);

// Report simple running errors
error_reporting  (E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings)
error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all PHP errors (use bitwise  63  in PHP 3)
error_reporting (E_ALL);