Voting

: min(two, eight)?
(Example: nine)

The Note You're Voting On

fadhilinjagi at gmail dot com
3 years ago
A simple and neat way to get the error level from the error code. You can even customize the error level names further.

<?php
$exceptions
= [
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
E_PARSE => "E_PARSE",
E_NOTICE => "E_NOTICE",
E_CORE_ERROR => "E_CORE_ERROR",
E_CORE_WARNING => "E_CORE_WARNING",
E_COMPILE_ERROR => "E_COMPILE_ERROR",
E_COMPILE_WARNING => "E_COMPILE_WARNING",
E_USER_ERROR => "E_USER_ERROR",
E_USER_WARNING => "E_USER_WARNING",
E_USER_NOTICE => "E_USER_NOTICE",
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED",
E_ALL => "E_ALL"
];

echo
$exceptions["1"];
$code = 256;
echo
$exceptions[$code];
?>

Output:
E_ERROR
E_USER_ERROR

This will need updating when PHP updates the error level names. Otherwise, it works just fine.

<< Back to user notes page

To Top