|
|
|
ถามเรื่อง Custom server error pages คือผมจะเขียนยังไงถ้าในกรณีที่มีคนเข้ามาในเว็บของเราแล้ว มันเกิด Error |
|
|
|
|
|
|
|
ทดลองเอาไปใช้ดูนะครับ หวังว่าคงจะช่วยได้ สงสัยก็ลองถามดูได้นะครับ
Code (PHP)
<?php
if(@$_GET["err"]!="") { exit($err); };
$old_error_handler = set_error_handler("myErrorHandler");
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
$errorpage = "index.php";
$errortype = array (
E_ERROR => "Error",
E_WARNING => "Warning",
E_PARSE => "Parsing Error",
E_NOTICE => "Notice",
E_CORE_ERROR => "Core Error",
E_CORE_WARNING => "Core Warning",
E_COMPILE_ERROR => "Compile Error",
E_COMPILE_WARNING => "Compile Warning",
E_USER_ERROR => "User Error",
E_USER_WARNIN => "User Warning",
E_USER_NOTICE => "User Notice",
E_STRICT => "Runtime Notice"
);
$dt = date("Y-m-d H:i:s (T)");
$err = "$dt\n";
$err .= "$errno [$errortype[$errno]]\n";
$err .= "$errfile [line $errline]\n";
$err .= "$errstr\n";
$err .= "Please contact admin as needed to report any problems you may be having.\n";
$err = eregi_replace("\n", "<br>", $err);
header("Location: $errorpage?err=$err");
exit();
}
?>
|
|
|
|
|
Date :
2009-02-26 17:57:58 |
By :
p_latplee |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ต้องตั้งค่าอะไรเพิ่มเติมหรือปล่าวครับ
|
|
|
|
|
Date :
2009-02-27 19:11:00 |
By :
maccit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2009-02-27 23:12:11 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โปรแกรมมัน error throw new NotImplementedException
|
|
|
|
|
Date :
2011-01-04 15:16:44 |
By :
p |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|