exception class list for all server error in laravel
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:
- Syntax error or access violation: 1071 Specified key was too long; max key lengt
- composer create project laravel 7
- extend php maximum execution time
- append rand php to string
- database seeder laravel 8
- find string length php
- add datetime to datetime php
- Line : 83 -- syntax error, unexpected end of file php
- New York Yankees
- adding days in date, php
- 12:30 am time format validation in laravel
- convert to string php
- create crandon string php
- create project in laravel
- Uncaught RedisException: Redis server went away in
- add more data to variable php
- charctar count php
- chacke if string contains word php
- date + 14 days php
- file form validation codeigniter
- curend date phph
- exception handling class php
- date php format minute
- base64 dencode GET variables in PHP