PHP/MySQL,HTML,JavaScript,Java Programming examples. Free Software, Earn Money Online.
Error Handling in PHP
It is better to store error messages in log files instead of displaying to users.
Settings to be done in php.ini configuration file.
1) Set display_errors to off.
display_errors = Off
Logging errors into a log file in PHP
You can create a log file in which all the errors occured can be stored for further reference.
Insert following code in each PHP page where you want to display custom error page.
<?php
function myhandler($eno,$edesc)
{
include_once('error.html');
echo "Detail: $edesc <br/>";
}
set_error_handler('myhandler');
?>
error.html
<html>
<head>
<style>
body
{
font: 8pt/11pt verdana;
}
</style>
<title>Ohh! Error Ocurred. </title>
</head>
<body>
<div style="border:solid #999;background:#ccefff;width:400px;height:100px">
<h3><span style="COLOR: red; FONT: 18pt/21pt verdana">! Opps </span> The page cannot be
displayed</h3>
<a href="http://kbkashid.blogspot.com">Home Page--> </a>
</div>
</body>
</html>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Thanks for visiting my Blog!