Which of the followings are used in 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:
- create a class in php
- add day to time php
- array value loop in php
- Tests\Feature\BlogTest > user can delete post 162 Illuminate\Encryption\MissingAppKeyException No application encryption key has been specified.
- composer require laravel/ui for laravel 6
- check if array has value php
- doctrine mongodb native query
- create laravel migration
- Hash::extract
- PHP Warning: Module 'soap' already loaded in Unknown on line 0
- base64 in php
- !array_key_exists($id, $this->items)
- do something after redirect php
- Fatal error: Allowed memory size of 1073741824 bytes exhausted (trie
- add hour minute in datetime in php
- echo errors of php
- array map php
- file de redirection php
- cache::remember with json
- Laravel users_email_unique
- check composer version windows
- create a laravel project php 8
- clear application cache in LARAVEL
- converting string to uppper case in PHP