thinkphp Frame 404 Page Setup Only three steps, 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.
In many sites will have the use of 404 pages, in the thinkphp framework of how to set up, next I introduce one of the methods, the specific content is as follows
The first step: build a EmptyController.class.php in the Home/comtroller in the thinkphp framework with the following code:
<?phpnamespace homecontroller;use thinkcontroller;class Emptycontroller extends controller{ //null 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, with the following code:
<?phpnamespace homecontroller;use thinkcontroller;class Publiccontroller 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 of the page jump after you appear 404. Need to correspond with your own 404.html page placement bit.
Step three: let all other controllers inherit the PublicController.class.php in the second step, such as:
<?phpnamespace homecontroller;//use Thinkcontroller;class Indexcontroller extends Publiccontroller {public function index () { * * * }} }? >
Note: use Thinkcontroller; Comment out
The above is the Thinkphp 404 page setup of all the content, I hope that you learn PHP programming help.
http://www.bkjia.com/PHPjc/1127900.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127900.html techarticle thinkphp Frame 404 Page Setup is only three steps, 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. ...