Basic features of Exception Handling 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:
- applying multiple order by in codeigniter
- cache:clear php artisan
- SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
- artisan clean cache
- php random string generator
- clear cahce laravel
- composer global in laravel means
- desired date in pgp
- HOW TO GET LAST INSERTED ID FROM TABLE IN SQL IN CODEIGNITER
- encontrar una palabra dentro de una cadena php
- ?name="" value in php
- db seed in laravel
- disable timestamp laravel
- add checkbox in server side datatable laravel
- cahgne date format in php
- associtive array php
- exception ph
- current date() in php
- date math sql php
- eloquent run seeder
- PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Sp ecified key was too long; max key length is 1000 bytes")
- count length string php
- check if key array php
- count characters php