+ 1
How to handle errors and throw exception in php?
2 odpowiedzi
+ 2
using try and catch block. you can genrate your own exception using throw exception.
<?php
try {
$error = 'Always throw this error';
throw new Exception($error);
// Code following an exception is not executed.
echo 'Never executed';
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
// Continue execution
echo 'Hello World';
?>
+ 1
always use var_dump(); on any variable to check for desired output and then check back your code if the output is not the desired one