您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 辽源分类信息网,免费分类信息发布

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

2024/5/3 9:19:00发布42次查看
这篇文章主要介绍了thinkphp中自定义错误页面和提示页面的方法,以一个完整的实例形式详细讲述了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 p { 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> <p id="notice"> <present name="message"> <p style="font: italic bold 2cm cursive,serif; color:green"> ok </p> <p class="success" style="width:100%;text-align:left;padding-left:10px;padding-right:10px"> <?php echo($message); ?> </p> <else/> <p style="font: italic bold 2cm cursive,serif; color:red"> × </p> <p class="error" style="width:100%;text-align:left;padding-left:10px;padding-right:10px"> </p> </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> </p> <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中自定义目录结构的设置方法
以上就是thinkphp中自定义错误页面和提示页面的详细内容。
辽源分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录