PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

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! Empty Seting youyr own custom Error messages instead of getting generic error messages!

Post by jamied_uk 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(),
?>






jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top


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