首頁 >php教程 >php手册 >Yii 配置默认controller和action

Yii 配置默认controller和action

WBOY
WBOY原創
2016-06-13 09:39:491395瀏覽

设置默认controller

  在/protected/config/main.php添加配置

<span 1</span> <?<span php
</span><span 2</span> <span return</span> <span array</span><span (
</span><span 3</span>     'name'=>'Auto',
<span 4</span>     'defaultController'=>'auto',
<span 5</span>     ...

  上述配置了默认的controller为AutoController.php

 

设置默认action

  在AutoController.php中设置

<span class</span> AutoController <span extends</span><span  CController
{
    </span><span public</span> <span $defaultAction</span> = 'test'<span ;

    </span><span public</span> <span function</span><span  actionTest()
    {
        </span>...<span 
    }
    </span>...

  此时访问xxxx/index.php会默认转到xxxx/index.php?r=auto/test

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:PM2.5数据采集下一篇:phpcms学习总结