404,可直接将Exception对象传给$msg
null Core_Core::show_404( [ string/Exception $msg = null ] )
参数列表
参数 类型 描述 默认值 $msg
string/Exception
$msg null
public static function show_404($msg = null)
{
Core::close_buffers(false);
# 避免输出的CSS头试抛出页面无法显示
@header('Content-Type: text/html;charset=' . Core::config('core.charset'), true);
HttpIO::$status = 404;
HttpIO::send_headers();
if (null === $msg)
{
$msg = __('Page Not Found');
}
if (IS_DEBUG && class_exists('ErrException', false))
{
if ($msg instanceof Exception)
{
throw $msg;
}
else
{
throw new Exception($msg, 43);
}
}
if (IS_CLI)
{
echo $msg . CRLF;
exit();
}
try
{
$view = new View('error/404');
$view->message = $msg;
$view->render(true);
}
catch ( Exception $e )
{
list ( $REQUEST_URI ) = explode('?', $_SERVER['REQUEST_URI'], 2);
$REQUEST_URI = htmlspecialchars(rawurldecode($REQUEST_URI));
echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">' .
CRLF . '<html>' .
CRLF . '<head>' .
CRLF . '<title>404 Not Found</title>' .
CRLF . '</head>'.
CRLF . '<body>' .
CRLF . '<h1>Not Found</h1>' .
CRLF . '<p>The requested URL ' . $REQUEST_URI . ' was not found on this server.</p>' .
CRLF . '<hr />' .
CRLF . $_SERVER['SERVER_SIGNATURE'] .
CRLF . '</body>' .
CRLF . '</html>';
}
exit();
}