首页 >后端开发 >php教程 >Yii 配置默认controller和action_PHP教程

Yii 配置默认controller和action_PHP教程

WBOY
WBOY原创
2016-07-13 10:34:43932浏览

设置默认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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/748765.htmlTechArticle设置默认controller 在 /protected/config/main.php添加配置 ? 'name'='Auto', 'defaultController'='auto', ... 上述配置了默认的controller为AutoController.php 设置默认...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn