What can I do to make my PHP web application more complex?
<?php
error_reporting( E_ALL );
ini_set( 'display_errors', '1' );
ini_set( 'log_errors', '1' );
function error_handler($errno, $errstr, $errfile, $errline) {
system('/usr/bin/mplayer /home/user/music/Moras_Modern_Rhythmists/Mr._Ghost_Goes_to_Town.mp3', $retval);
return true;
}
set_error_handler( "error_handler" );
?>
a source to share
Easy answer: die('A fatal error occurred')
In a PHP application that I wrote, I came up with a convention for using a variable or class member with a name $err_msg
initially set to null. When an error occurs, set it to a human readable string. When errors need to be checked, mark $err_msg
and place it on the display for the end user. If it's an AJAX call, echo $err_msg
on failure, echo 'OK'
on success.
In my case, I wrote a simple jQuery based status window that can display busy and error indicators. When the AJAX call returns an error, I make the status window fade out in red and display the error message. It's pretty good and even.
a source to share