ThinkPHP中如何自定义错误页面和提示页面

发布时间:2021-07-02 16:27:21 作者:chen
来源:亿速云 阅读:138

本篇内容主要讲解“ThinkPHP中如何自定义错误页面和提示页面”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“ThinkPHP中如何自定义错误页面和提示页面”吧!

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

复制代码 代码如下:

'TMPL_EXCEPTION_FILE'=>'./Public/Tpl/error.html'


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

下面是我定制的错误页面

复制代码 代码如下:

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

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

$this->error();

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

复制代码 代码如下:

<!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 >  
ok   
</p>  
<div class="success" >  
<?php echo($message); ?>  
</div>  
<else/>  
<p >  
×  
</p>  
<div class="error" >  
</div>  
</present>
<p>  
在( <span id="sec" ><?php echo($waitSecond); ?></span> )秒后自动跳转,或直接点击 <a href="javascript:window.location='<?php echo($jumpUrl); ?>'">这里</a> 跳转<br>  
<span  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中如何自定义错误页面和提示页面”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

推荐阅读:
  1. java怎么设置自定义的错误页面
  2. 如何自定义jsp中的错误页面

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

thinkphp

上一篇:DOM基础以及php读取xml内容操作的方法

下一篇:C语言中怎么定义字符串

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》