This article describes how to customize error pages and prompt pages in ThinkPHP. It provides a complete example to describe how ThinkPHP implements custom error prompts and jumps to pages, it is a very common practical technique. if you need it, you can refer to the examples in this article to describe how to customize error pages and prompt pages in ThinkPHP. Share it with you for your reference. The specific implementation method is as follows:
When there are two methods in ThinkPHP, the error page _ 404 is displayed ('error information', 'Jump address'); halt ('prompt information ');
Both functions can customize the error page in the configuration file
The code is as follows:
'Tmpl _ EXCEPTION_FILE '=>'./Public/Tpl/error.html'
In this way, the page is displayed every time.
The following is my custom error page
The code is as follows:
Automatically jump in (3) seconds, or click here to stop the jump
$ This-> success ('error information', 'Jump address (preferably U () ', time );
$ This-> error ();
Below is the prompt page for changing ThinkPHP
The code is as follows:
Prompt message-ThinkPHP
OK
<? Php echo ($ message);?>
×
In (<? Php echo ($ waitSecond);?> ) Automatically jump in seconds, or directly click '"> here to jump
Stop
Script
Var seco = document. getElementByIdx_x ("sec ");
Var time = <? Php echo ($ waitSecond);?>;
Var tt = setInterval (function (){
Time --;
Seco. innerHTML = time;
If (time <= 0 ){
Window. location = '<? Php echo ($ jumpUrl);?> '
Return;
}
},1000 );
Function stop (obj ){
ClearInterval (tt );
Obj. style. display = "none ";
}
Script
I hope this article will help you with ThinkPHP framework programming.