2012-02-06 9 views

risposta

36

http://www.php.net/error_reporting

int error_reporting ([ int $level ])

Restituisce il vecchio livello error_reporting o il livello corrente se non viene dato alcun parametro del livello di .

È inoltre possibile utilizzare gli esempi forniti dal collegamento per eseguire il cast del livello (che viene restituito come numero intero) nella stringa. Per esempio:

function error_level_tostring($intval, $separator = ',') 
{ 
    $errorlevels = array(
     E_ALL => 'E_ALL', 
     E_USER_DEPRECATED => 'E_USER_DEPRECATED', 
     E_DEPRECATED => 'E_DEPRECATED', 
     E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', 
     E_STRICT => 'E_STRICT', 
     E_USER_NOTICE => 'E_USER_NOTICE', 
     E_USER_WARNING => 'E_USER_WARNING', 
     E_USER_ERROR => 'E_USER_ERROR', 
     E_COMPILE_WARNING => 'E_COMPILE_WARNING', 
     E_COMPILE_ERROR => 'E_COMPILE_ERROR', 
     E_CORE_WARNING => 'E_CORE_WARNING', 
     E_CORE_ERROR => 'E_CORE_ERROR', 
     E_NOTICE => 'E_NOTICE', 
     E_PARSE => 'E_PARSE', 
     E_WARNING => 'E_WARNING', 
     E_ERROR => 'E_ERROR'); 
    $result = ''; 
    foreach($errorlevels as $number => $name) 
    { 
     if (($intval & $number) == $number) { 
      $result .= ($result != '' ? $separator : '').$name; } 
    } 
    return $result; 
} 

uso come echo error_level_tostring(error_reporting(), ',');

+0

Brillante! Grazie per aver condiviso questo. – chrisdillon