<?php
function getErrorTypeByValue($type) {
$constants = get_defined_constants(true);
foreach ( $constants['Core'] as $key => $value ) { // Each Core constant
if ( preg_match('/^E_/', $key ) ) { // Check error constants
if ( $type == $value )
return( "$key=$value");
}
}
} // getErrorTypeByValue()
echo "[".getErrorTypeByValue( 1 ) . "]". PHP_EOL;
echo "[".getErrorTypeByValue( 0 ) . "]". PHP_EOL;
echo "[".getErrorTypeByValue( 8 ) . "]". PHP_EOL;
?>
Will give
[E_ERROR=1]
[]
[E_NOTICE=8]