yii怎么返回404

yii怎么返回404

1、首先進到y(tǒng)ii框架的frontendconfig文件夾下,里面有一個main.php文件,打開編輯,修改其中的控制器名和方法名:

yii怎么返回404

2、然后進到controllers控制器中,在控制器code里面添加error方法。

yii怎么返回404

3、最后在V層創(chuàng)建你的視圖(這里是error.php):

<?php use yiihelpersHtml; $this->title?=?$name; $this-&gt;context-&gt;layout?=?false;?//不使用布局,或者改為自己所需要使用的布局 ?&gt; nbsp;HTML?PUBLIC?"-//W3C//DTD?HTML?4.01//EN"?"http://www.w3.org/TR/html4/strict.dtd"&gt;   ????<meta> ????<title>這個..?頁面沒有找到!!!_SJ5D.COM</title> ????<style>         body{ margin:0; padding:0; background:#efefef; font-family:Georgia, Times, Verdana, Geneva, Arial,          Helvetica, sans-serif; }         div#mother{ margin:0 auto; width:943px; height:572px; position:relative; }         div#errorBox{ background: url(/404_bg.png) no-repeat top left;width:943px; height:572px;margin:auto;}         div#errorText{ color:#39351e; padding:146px 0 0 446px }         div#errorText p{ width:303px; font-size:14px; line-height:26px; }         div.link{ /*background:#f90;*/ height:50px; width:145px; float:left; }         div#home{ margin:20px 0 0 444px;}         div#contact{ margin:20px 0 0 25px;}         h1{ font-size:40px; margin-bottom:35px; }     </style><div> ????<div> ????????<div> ????????????<h1>Sorry..頁面沒有找到!</h1> ????????????<p> ????????????????似乎你所尋找的網(wǎng)頁已移動或丟失了。 ????????????</p> <p>或者也許你只是鍵入錯誤了一些東西。</p> ????????????請不要擔(dān)心,這沒事。如果該資源對你很重要,請與管理員聯(lián)系。 ???????????? ????????????<p> ????????????????火星不太安全,我可以免費送你回地球 ????????????</p> ????????</div> ????????<a> ????????????<div></div> ????????</a> ????????<a> ????????????<div></div> ????????</a> ????</div> </div>  

php中文網(wǎng),大量的免費yii入門教程,歡迎在線學(xué)習(xí)!

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點贊13 分享