2015-02-14 09:01:00
ThinkPHP中,某一个模块或方法不存在时,自定义404页面的方法
1、在Action目录中新建一个文件名为EmptyAction.class.php的文件
2、代码:
[php] view plaincopyprint?
- <?php
- class EmptyAction extends Action{
- //所请求的模块不存在时,默认执行的模块
- public function index(){
- header("HTTP/1.0 404 Not Found");//404状态码
- $this->display("Common:404"); //显示自定义的404页面模版
- }
- function _empty(){
- header("HTTP/1.0 404 Not Found");//404状态码
- $this->display("Common:404");//显示自定义的404页面模版
- }
- }
- ?>
更多精彩内容:各种AI课程、技能课程、黑科技软件、网站小程序源码、副业小项目、PPT模板等精品素材、电商课程、推广引流课程等,尽在 天边资源网 。