catching error and pass php
Try catch comes under exception handeling concept where using this we control the runtime error and modify the message as we want.
// function created with exception throw
function checkdata($number){
if($number > 10){
throw new Exception("Number is greater than 10");
}
return true;
}
// try block starts
try{
checkdata(15);
echo "The number is below 10";
}
// catch block
catch(Exception $e){
echo "Message :".$e->getMessage();
}
In above code if condition is not satisfied then it will throw exception and which gets caught by catch block and show the error message.
Also in PHP:
- date function is one day after strtotime
- change native password in phpmyadmin
- date formate php
- dropzone uploader php
- <Directory /usr/share/phpMyAdmin/> Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </Directory>
- creating web application with php and sparql on backend
- clear cahche laravel
- can we acces session variable in two files
- body field yml drupal config
- add one day to date php
- aadd day in date php
- extract contact page url php
- Add “Affected Products” in catalog price rule
- array key exstis php
- add one day to date in php
- clear cache in php artisan
- array reverse in php
- declare array php
- date method php
- array sort array reverse php
- check on off in php code
- convert timestamp to date in php
- find array unique php
- array_reverse in php