jump to navigation

handling functions errors September 24, 2008

Posted by Nsh15 in Basic PHP programming, php.
Tags: , , , ,
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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.