php equivilent to Java's try{}catch

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

php equivilent to Java's try{}catch

Post by phpScott »

Is there a php counterpart to Java's try{}catch synatax?
What I am trying to do is if my script encounters an error instead of getting the php error on the screen I want to be able to deal with the error myself.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

from the manual:
All PHP expressions can also be called with the "@" prefix, which turns off error reporting for that particular expression. If an error occurred during such an expression and the track_errors feature is enabled, you can find the error message in the global variable $php_errormsg.
you can use these, the array functions, and some if statements to make your own version of it.
sav
Forum Newbie
Posts: 8
Joined: Mon Oct 21, 2002 7:29 pm

Post by sav »

See PHP manual: Chapter 16. Error Handling - php error nandling code sample included, XXVII. Error Handling and Logging Functions
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

thanks

Post by phpScott »

That was exactly what I was looking for. The overhead seems a little high though if there is an error, but I won't complain as hopefully there won't be to many errors.
phpScott
Post Reply