I've tried the following:
<?php
function shutdown_find_exit()
{
exit(50);
}
register_shutdown_function('shutdown_find_exit');
trigger_error("Fatal error", E_USER_ERROR);
?>
But that still exists with an error code of 255.
I'm trying to have an error code of 50 returned.
I'm checking it with the following bash script:
php tester.php
status=$?
echo Exit Code: ${status}
Updated code based on the accepted answer for anyone interested:
<?php
function shutdown_find_exit()
{
exit('50');
}
register_shutdown_function('shutdown_find_exit');
trigger_error("Fatal error", E_USER_ERROR);
?>
and the bash script
output="$(php tester.php)"
status=$?
echo Exit Code: ${status}
if [[ $output == *"50"* ]]
then
echo "Got 50";
fi
70would be a better result code,EX_SOFTWARE.)