Home  >  Article  >  Backend Development  >  Yii configure default controller and action_PHP tutorial

Yii configure default controller and action_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:34:43853browse

Set default controller

Add configuration in

/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>     ...

The default controller configured above is AutoController.php

Set default action

 Set in 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>...

At this time, accessing xxxx/index.php will by default go to xxxx/index.php?r=auto/test

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/748765.htmlTechArticleSet the default controller Add configuration in /protected/config/main.php? 'name'='Auto', ' defaultController'='auto', ... The above configures the default controller for AutoController.php to set the default...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn