Seting youyr own custom Error messages instead of getting generic error messages!

Go down

Seting youyr own custom Error messages instead of getting generic error messages!

Post by jamied_uk on 1st December 2013, 15:47

Code:
<?php
function myErrorHandler() {
echo " ";
}
// this will return nothing instead of an error, this can be customised to send an email or
//log to a logfile.txt or display an error of your choosing!
?>

Usage code is below

<?php
set_error_handler("myErrorHandler");
try {
include "somefile.php";
} catch (Exception $e) {
echo $e->getMessages();
}
?>
Code:
Example 2:

<?php
function myErrorHandler($eNum, $eMsg, $errFile, $errLine) {
 throw new ErrorException($errMsg, $errNum, 0, $errFile, $errLine);
}
// this will return nothing instead of an error, this can be customised to send an email or
//log to a logfile.txt or display an error of your choosing!
?>



Usage code is below

<?php
set_error_handler("myErrorHandler");
try {
include "somefile.php";
} catch (Exception $e) {
echo "<b>", $e->getMessages(), "</b>";
}
// you could also use $e->getTraceAsString(),
?>






avatar
jamied_uk
Admin

Posts : 2320
Join date : 2010-05-09
Age : 35
Location : UK

http://address-shortner.co.uk

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum