exception handling keyword in php
''for'' ($i = 0; $i < 5; ++$i) {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:
- dompdf/dompdf v0.8.5 requires ext-dom
- base64 php decode with password
- composer install laravel 7 not installing
- avoid sql injection in password field
- corsair k70 rgb mk.2
- cviebrock/eloquent-sluggable
- 500 server error laravel handle
- check contain word php
- cakephp login session
- codeigniter validation text length
- check value contains numbers or letters php
- Armstrong number
- $this- attribute laravel
- current date and time php
- Method [logoutOtherDevices] does not exist laravel
- add a snippet in twig shopware 6
- check if string include char php
- composer require laravel/ui not working laravel 7
- blade loop last
- check if key in array excist
- php uppercase
- Remove values from select list based on condition
- - tijsverkoyen/css-to-inline-styles 2.2.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- check if date between two dates laravel