can you use return in catch 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:
- contains php
- disable timestamps laravel
- date('h:m:i')
- Allowed memory size of 134217728 bytes exhausted laravel
- !is_null in laravel
- codeigniter get last insert id model
- csv to json php
- Created Migration: laravel
- clear remeber cache laravel
- check contain in string php
- convert string to int php 7
- date time with am pm in php
- download laravel for php 5.6 windows
- check sizee string laravel
- codeigniter redirect
- date( ) php
- ->with('success','msj')
- disable register auth laravel
- android studio clear cache
- create new project in laravel 7
- extend multiple classes in php
- catch error exception php
- detect duplicate in array php
- check for keys in array