加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

ThinkPHP中自定义错误页面和提示页面实例

发布时间:2020-12-13 02:11:47 所属栏目:PHP教程 来源:网络整理
导读:《:ThinkPHP中自定义错误页面和提示页面实例》要点: 本文介绍了:ThinkPHP中自定义错误页面和提示页面实例,希望对您有用。如果有疑问,可以联系我们。 本篇章节讲解ThinkPHP中自定义错误页面和提示页面的办法.供大家参考研究.具体实现办法如下:

《:ThinkPHP中自定义错误页面和提示页面实例》要点:
本文介绍了:ThinkPHP中自定义错误页面和提示页面实例,希望对您有用。如果有疑问,可以联系我们。

本篇章节讲解ThinkPHP中自定义错误页面和提示页面的办法.分享给大家供大家参考.具体实现办法如下:PHP实战

在ThinkPHP中有两个办法时提示错误页面 _404('错误信息','跳转的地址');halt('提示信息');
这两个函数都可以自定义错误页面在配置文件中加 PHP实战

代码如下:
'TMPL_EXCEPTION_FILE'=>'./Public/Tpl/error.html'

这样每次就会跳转到这个页面.

下面是我定制的错误页面
PHP实战

代码如下:
在( 3 )秒后自动跳转,或直接点击 这里 跳转 停止

$this->success('错误信息','跳转的地址(最好用U())',时间);PHP实战

$this->error();PHP实战

下面是我改变ThinkPHP中的提示页面
PHP实战

代码如下:
<!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> )秒后自动跳转,或直接点击 <a href="javascript:window.location='<?php echo($jumpUrl); ?>'">这里</a> 跳转<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框架程序设计有所赞助.PHP实战

编程之家培训学院每天发布《:ThinkPHP中自定义错误页面和提示页面实例》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读