Craur
Craur copied to clipboard
use stderr for error messages in cli
ini_set('display_errors', 'STDERR'); redirects exceptions and such to stderr without polluting the stdout
"Although display_errors may be set at runtime (with ini_set()), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed."
http://us3.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
Tried it with some "unexpected" exception and shell exit code was 255, but 2>/dev/null redirection did not work. Needs investigation. At least exceptions can be catched and then a default error message to stderr with exit code may be presented to the user... :-)