thinkphp frame 404 Page Setup, thinkphp404
The 404 page is the optimization of an error behavior when the system cannot find the requested action method and cannot find the requested controller name .
The first step: Build a EmptyController.class.php in the Home/comtroller in the thinkphp framework with the following code:
namespace Home\controller;
Use Think\controller;
Class Emptycontroller extends controller{
Empty Operation _empty () method
function _empty () {
Header ("http/1.0 404 Not Found");
$this, display ("public:404");
}
function index () {
Header ("http/1.0 404 Not Found");
$this-Dislay ("public:404");
}
}
?>
Note: where header ("http/1.0 404 Not Found") is defined this status code is not 404.
Step Two: Build a common class PublicController.class.php in Home/comtroller in the thinkphp framework, withthe following code:
Phpnamespace Home\controller; Use Think\controller; class extends controller{ function _empty () { header("location:/bbs/thinkphp/ 404.html ");} }? >
Note: the /bbs/thinkphp/404.html in the header ("location:/bbs/thinkphp/404.html") Is the address that you appear after 404 page jump, need to correspond with own 404.html page place bit.
Step three: Let all other controllers inherit the PublicController.class.php in the second step , such as:
Phpnamespace Home\controller; // Use Think\controller; class extends Publiccontroller { publicfunction index () { * * * * }}? >
Note: Use think\controller; Comment out
Complete
http://www.bkjia.com/PHPjc/1125677.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125677.html techarticle thinkphp frame 404 Page setup, thinkphp404 404 page that is, the system can not find the requested action method and the name of the requested controller can not find an error behavior optimization. The first step ...