|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Help: PHP exceptions handling explanation needed Hi, Help: PHP exceptions handling explanation needed Can someone please explain me the basics & importance of exception handling in PHP? say PHP 5? I have not learned PHP in details but know some basics only. My friend told me to use exception handling but i don't know how to. I suppose this exception handling is a part of Java language. Thanks in advance. Regards, strangist |
#2
| |||
| |||
Re: Help: PHP exceptions handling explanation needed What is an Exception PHP 5: Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception. This is what normally happens when an exception is triggered:
Different error handling methods:
Basic Use of Exceptions When an exception is thrown, the code following it will not be executed, and PHP will try to find the matching "catch" block. If an exception is not caught, a fatal error will be issued with an "Uncaught Exception" message. Try, throw and catch Proper exception code should include: 1. Try - A function using an exception should be in a "try" block. If the exception does not trigger, the code will continue as normal. However if the exception triggers, an exception is "thrown" 2. Throw - This is how you trigger an exception. Each "throw" must have at least one "catch" 3. Catch - A "catch" block retrieves an exception and creates an object containing the exception information Lets try to trigger an exception with valid code: PHP Code: Code: Message: Value must be 1 or below |
#3
| |||
| |||
Re: Help: PHP exceptions handling explanation needed Error Handling and Logging This is what you must go through. Here exception handling is explained in details & with examples. Exception handling is a must. Either your code fails, or external libraries you?ve grown to accept produce faults outside of your control. This is an interesting Article on Exception handling I hope this helps you. |
#4
| |||
| |||
Re: Help: PHP exceptions handling explanation needed Thanks a lot guys for the explanation & the prompt reply. I hope these articles on error handling point me in right direction & ill be posting my problems in this section if I have problem understanding any concept. Thanks again. |
![]() |
|
Tags: exceptions handling, explanation, php, php5 |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Exceptions of PHP in set_exception_handler? | - Empty Shell - | Software Development | 5 | 23-02-2010 02:12 AM |
What are Exceptions in PHP 5? | DANIEL 602 | Software Development | 5 | 23-02-2010 01:35 AM |
What is Log .NET Exceptions | Agneya | Software Development | 4 | 07-02-2010 01:34 AM |
PHP Error exceptions | nehal_serpa | Software Development | 3 | 01-05-2009 06:55 PM |
Suggestions needed on handling of suspected invalid OS with crack tool installed | jenster | Operating Systems | 5 | 17-07-2008 02:12 PM |