Try and catch in Error Handling in PHP.
In this tutorial, we are showing error handling because it can be used in multiple programs for checking error messages. There are multiple scripts those use multiple exceptions to check into multiple conditions. we can also use multiple conditions like: - if, if else blocks into units, switch case, nested conditions with exception. every exception may have different exception using class module and returns different error statements and messages:We can easily understand with the help of Example: -
getLine().' in '.$this->getFile() .': '.$this->getMessage().' This is not a valid EMail ID'; return $errorMsg; } } $emailid = "ashok@estuffcage...com"; try { //check if if(filter_var($emailid, FILTER_VALIDATE_EMAIL) === FALSE) { //throw an exception if your given email is not valid throw new mynewException($emailid); } //check for "example" in mail address if(strpos($emailid, "example") !== FALSE) { throw new myException("$emailid is an example e-mail"); } } catch (mynewException $s) { echo $s->errorMessage(); } catch(myException $s) { echo $s->getMessage(); } ?>
You Might Also Read : -
- How to Send Bulk Emails in java Technology.
- How to Check all Checkboxes by clicking one checkbox.
- How to Completely Disable cache for PHP project.
- How to Send data using Ajax and JavaScript into database.
- Dynamically Add Input fields into the form using JQuery.
- Magento Issues While Installing a New Installation or Theme.
- jQuery Techniques For URL, How to Get Query strings and Hashvalue Parameters.
0 comments :
Post a Comment