Home  >  Article  >  php教程  >  一个简单的返回指定错误代码,错误页面的函数

一个简单的返回指定错误代码,错误页面的函数

WBOY
WBOYOriginal
2016-06-07 11:45:241043browse

httpstatus('404');
将向客户端发送一个404错误,并且错误页面是可以自定义的。
将函数放在common.php内,自动加载即可随意调用了
/**<br>  * 返回错误代码,将错误页面放在入口文件目录./Public/httpstatus下,命名为 404.html,403.html,503.html等等<br>  * @param $string 错误代码<br>  * @param $msg 错误信息例如NOT FOUND,可以省略<br>  */<br> function httpstatus($string="404",$msg=""){<br>     header("http/1.1 {$string} {$msg}");<br>     include './Public/httpstatus/'.$string.'.html';<br>     exit;<br> }

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn