5 examples of exception handling in 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:
- empty table in laravel
- date( c time()) php
- clear cach php artisan
- exclude php
- array check if element contains key
- array_sum in multidimensional array php
- create laravel command to clear cache
- 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php
- check if number is multiple of 3 in php
- append single qoute arounf variable in php string
- Laravel Google Line Chart
- find if string contains any of character php
- @foreac laravel
- all uppercase php
- check array key exists php js
- base64 file php
- date du joure n php
- check if word in string
- file upload in php through ajax
- composer set php version
- echo err in php
- create database seeder in laravel
- @ watch: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
- find str in string php