how to handle exceptions in php4(please give example also)
Moderator: General Moderators
how to handle exceptions in php4(please give example also)
how to handle exceptions in class just by creating the instance on php4. please give me answer with some coding examples.
To quote myself from this thread:
Also, I think I explained the alternatives in said thread pretty well. Might want to get back to it.foobar wrote: There is no exception handling in PHP4.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
In PHP4 you can't catch the errors.rajan wrote:but how to handle the error in class ? how to get the error messages or u can say user generated error messages from inside class?
You can surpress the output and use your own error output by using the @ syntax.
Code: Select all
if ($foo = @some_undefined_function()) echo $foo;
else echo 'WTF?? Function is undefined';You can also log the errors to a log file rather than displaying them on screen. As ~foobar says... exception handling is new to PHP5.
make use of trigger_error() and set_error_handler()
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US