本文实例讲述了thinkphp中自定义错误页面和提示页面的方法。分享给大家供大家参考。具体实现方法如下:
在ThinkPHP中有两个方法时提示错误页面 _404('错误信息','跳转的地址');halt('提示信息');
这两个函数都可以自定义错误页面在配置文件中加
这样每次就会跳转到这个页面。
下面是我定制的错误页面
$this->success('错误信息','跳转的地址(最好用U())',时间);
$this->error();
下面是我改变ThinkPHP中的提示页面
<br><p style="font: italic bold 2cm cursive,serif; color:green"> <br> ok <br></p> <br><div class="success" style="width:100%;text-align:left;padding-left:10px;padding-right:10px"> <br><?php echo($message); ?> <br> </div> <br><else></else> <br><p style="font: italic bold 2cm cursive,serif; color:red"> <br> × <br></p> <br><div class="error" style="width:100%;text-align:left;padding-left:10px;padding-right:10px"> <br> </div> <br><br><p> <br> 在( <span id="sec" style="color:blue;font-weight:bold"><?php echo($waitSecond); ?></span> )秒后自动跳转,或直接点击 <a href="javascript%EF%BC%9Awindow.location='<?php%20echo(%24jumpUrl);%20?>'">这里</a> 跳转<br> <br><span style="display:block;text-decoration:underline;cursor:pointer;line-height:25px" onclick="stop(this)">停止</span> <br></p> <br>
<script> <br> var seco=document.getElementByIdx_x("sec"); <br> var time=<?php echo($waitSecond); ?>; <br> var tt=setInterval(function(){ <br> time--; <br> seco.innerHTML=time; <br> if(time<=0){ <br> window.location='<?php echo($jumpUrl); ?>' <br> return; <br> } <br> }, 1000); <br> function stop(obj){ <br> clearInterval(tt); <br> obj.style.display="none"; <br> } <br> </script>
希望本文所述对大家的ThinkPHP框架程序设计有所帮助。










