PHP Exception Handling
Exception Handling:
In the case of specific error (exceptional) condition, exception handling is used to change the
issue of code activity. This action is called an exception.
issue of code activity. This action is called an exception.
This usually causes to happens when an exception its generate:
- The current index level is stored.
- Exclude a predefined (optional) code execution code handling function
- Count on the position, the controller can then proceed execution from the stored data, the script can stop execution or the script can continue from somewhere else in the code.
We See Distant Error Handling Methods:
- Basic applications of exceptions
- Creating a procedure exception handler.
- Many Exceptions.
- The exception was heaved back
- Ambiance a high level exception handler
Exceptions may only be used with flaw conditions and should not be used to go to another location
in the specified location.
in the specified location.
Basic Use of Exceptions:
If an exception is exited, the following code will not be implemented, and the PHP "catch" block will
attempt to find.
attempt to find.
If there is no exception, a dangerous error will be provided with a "Uncaught Exception" message.
Try, throw and Catch:
To avoid the error from the Exception handling program, you need to create a valid code to manage the exception.
The correct exception code should be admitted:
Try- Using an exception would require a function to be a "try" block. If the exception is not provoked, the
code will continue normally. Although there are exceptional triggers, an exception "throw away"
code will continue normally. Although there are exceptional triggers, an exception "throw away"
Throw- This is what you exceptionally stimulate. Each "throw" must have partially one "catch"
Catch- A "catch" block collect an exception and creates an object accommodate the exception information.
Creating a Custom Exception Class:
To create a custom exception handler you have to create a special class called functions when a exception
appears in Best PHP Course in Chennai. The class must be an exemption of the extension class.
appears in Best PHP Course in Chennai. The class must be an exemption of the extension class.
Custom Exception Class The exception of PHP Course in Chennai exceeds the equity in the class and you can
add custom functions.
add custom functions.
Multiple Exceptions:
The script can be use several exceptions to verify many conditions.
You can use a number of blocks, a switch, or a number of exceptions. These exceptions may use different exception
classes and can withdraw different latent messages
classes and can withdraw different latent messages
Comments
Post a Comment