ThinkPHP中自定義錯誤頁面和提示頁面實(shí)例
本文實(shí)例講述了ThinkPHP中自定義錯誤頁面和提示頁面的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
在ThinkPHP中有兩個方法時提示錯誤頁面 _404('錯誤信息','跳轉(zhuǎn)的地址');halt('提示信息');
這兩個函數(shù)都可以自定義錯誤頁面在配置文件中加
這樣每次就會跳轉(zhuǎn)到這個頁面。
下面是我定制的錯誤頁面
$this->success('錯誤信息','跳轉(zhuǎn)的地址(最好用U())',時間);
$this->error();
下面是我改變ThinkPHP中的提示頁面
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>提示消息 - ThinkPHP</title>
<style type="text/css">
body { font: 75% Arail; text-align: center; }
#notice { width: 300px; background: #FFF; border: 1px solid #BBB; background: #EEE; padding: 3px;
position: absolute; left: 50%; top: 50%; margin-left: -155px; margin-top: -100px; }
#notice div { background: #FFF; padding: 30px 0 20px; font-size: 1.2em; font-weight:bold }
#notice p { background: #FFF; margin: 0; padding: 0 0 20px; }
a { color: #f00} a:hover { text-decoration: none; }
</style>
</head>
<body>
<div id="notice">
<present name="message">
<p style="font: italic bold 2cm cursive,serif; color:green">
ok
</p>
<div class="success" style="width:100%;text-align:left;padding-left:10px;padding-right:10px">
<?php echo($message); ?>
</div>
<else/>
<p style="font: italic bold 2cm cursive,serif; color:red">
×
</p>
<div class="error" style="width:100%;text-align:left;padding-left:10px;padding-right:10px">
</div>
</present>
<p>
在( <span id="sec" style="color:blue;font-weight:bold"><?php echo($waitSecond); ?></span> )秒后自動跳轉(zhuǎn),或直接點(diǎn)擊 <a href="javascript:window.location='<?php echo($jumpUrl); ?>'">這里</a> 跳轉(zhuǎn)<br>
<span style="display:block;text-decoration:underline;cursor:pointer;line-height:25px" onclick="stop(this)">停止</span>
</p>
</div>
<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>
</body>
</html>
希望本文所述對大家的ThinkPHP框架程序設(shè)計(jì)有所幫助。
- thinkPHP5(TP5)實(shí)現(xiàn)改寫跳轉(zhuǎn)提示頁面的方法
- thinkphp在php7環(huán)境下提示Cannot use ‘String’ as class name as it is reserved的解決方法
- ThinkPHP做文字水印時提示call an undefined function exif_imagetype()解決方法
- ThinkPHP調(diào)用common/common.php函數(shù)提示錯誤function undefined的解決方法
- Thinkphp自定義美化success和error提示跳轉(zhuǎn)頁面代碼實(shí)例
相關(guān)文章
使用laravel的migrate創(chuàng)建數(shù)據(jù)表的方法
今天小編就為大家分享一篇使用laravel的migrate創(chuàng)建數(shù)據(jù)表的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09簡單易用的php數(shù)據(jù)庫pdo操作類(curd?demo)
這篇文章主要介紹了簡單易用的php數(shù)據(jù)庫pdo操作類(curd?demo),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-10-10解決Linux下php-fpm進(jìn)程過多導(dǎo)致內(nèi)存耗盡問題
這篇文章主要介紹了解決Linux下php-fpm進(jìn)程過多導(dǎo)致內(nèi)存耗盡問題,需要的朋友可以參考下2017-12-12thinkphp3.2框架中where條件查詢用法總結(jié)
這篇文章主要介紹了thinkphp3.2框架中where條件查詢用法,總結(jié)分析了thinkphp3.2中where條件查詢中常用的各種查詢條件、以及各種復(fù)合查詢實(shí)現(xiàn)方法,需要的朋友可以參考下2019-08-08PHP curl模擬登錄帶驗(yàn)證碼的網(wǎng)站
最近接了個項(xiàng)目,其中有需求是要登錄帶驗(yàn)證碼的網(wǎng)站,獲取數(shù)據(jù),但是我們不可能人為的一直去記錄數(shù)據(jù),想通過自動采集的方式進(jìn)行,下面小編給大家?guī)淼南嚓P(guān)代碼,對php curl 模擬登錄帶驗(yàn)證碼的網(wǎng)站感興趣的朋友一起學(xué)習(xí)吧2015-11-11tp5(thinkPHP5框架)captcha驗(yàn)證碼配置及驗(yàn)證操作示例
這篇文章主要介紹了tp5(thinkPHP5框架)captcha驗(yàn)證碼配置及驗(yàn)證操作,結(jié)合實(shí)例形式分析了基于thinkPHP5框架的captcha驗(yàn)證碼配置及驗(yàn)證操作具體步驟與相關(guān)注意事項(xiàng),需要的朋友可以參考下2019-05-05CentOS 7.2 下編譯安裝PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法詳解(mini版
這篇文章主要介紹了CentOS 7.2 mini版本下編譯安裝PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-09-09