国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

ThinkPHP中自定義錯誤頁面和提示頁面實例

2024-05-04 23:27:50
字體:
供稿:網(wǎng)友
這篇文章主要介紹了ThinkPHP中自定義錯誤頁面和提示頁面的方法,以一個完整的實例形式詳細講述了ThinkPHP實現(xiàn)自定義錯誤提示與跳轉(zhuǎn)頁面的方法,是非常常見的實用技巧,需要的朋友可以參考下
 
 

本文實例講述了ThinkPHP中自定義錯誤頁面和提示頁面的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

在ThinkPHP中有兩個方法時提示錯誤頁面 _404('錯誤信息','跳轉(zhuǎn)的地址');halt('提示信息');
這兩個函數(shù)都可以自定義錯誤頁面在配置文件中加

復(fù)制代碼代碼如下:
'TMPL_EXCEPTION_FILE'=>'./Public/Tpl/error.html'

這樣每次就會跳轉(zhuǎn)到這個頁面。

 

下面是我定制的錯誤頁面

復(fù)制代碼代碼如下:
在( 3 )秒后自動跳轉(zhuǎn),或直接點擊 這里 跳轉(zhuǎn) 停止

 

$this->success('錯誤信息','跳轉(zhuǎn)的地址(最好用U())',時間);

$this->error();

 

下面是我改變ThinkPHP中的提示頁面

復(fù)制代碼代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
<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),或直接點擊 <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è)計有所幫助。


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 梅州市| 清水河县| 建水县| 临海市| 吴桥县| 上虞市| 泰和县| 江川县| 阿巴嘎旗| 迁西县| 溆浦县| 邓州市| 辽源市| 长海县| 隆德县| 册亨县| 莒南县| 汽车| 栾川县| 叶城县| 桑植县| 天峻县| 淳安县| 鹤峰县| 唐海县| 宣城市| 上饶市| 滕州市| 清水河县| 常州市| 宾川县| 紫阳县| 新巴尔虎右旗| 镇原县| 景德镇市| 宕昌县| 英吉沙县| 彰化县| 灌阳县| 赤水市| 万山特区|