handling functions errors September 24, 2008
Posted by Nsh15 in Basic PHP programming, php.Tags: die, error failuer in functions, exit, handling error, php
trackback
Sometimes functions fail, sad but true. ur script should anticipate any possible function failer and handle the situation like displaying ur wn message error. this can be done using die statement
function_name () or die(“ur message“);
The die statement stops the script and prints out whatever u haved entered in its message. is is when the function returns false !
but remeber that u should shut off the display for error messages, otherwise ur used will c 2 error messages.
U can also handle possible functions faileres by using the function call as condition.
if (!function_name($variable))
{
echo “ur error message here“;
exit();
}
the exit statement does the same as die statement!
Comments»
No comments yet — be the first.