yii框架配置默认controller和action示例

前端之家收集整理的这篇文章主要介绍了yii框架配置默认controller和action示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

设置默认controller

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

代码如下:
PHP
return array(
'name'=>'Auto',
'defaultController'=>'auto',

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

设置默认action

在AutoController.PHP中设置

代码如下:
class AutoController extends CController
{
public $defaultAction = 'test';

public function actionTest()
{
...
}
...

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

原文链接:https://www.f2er.com/php/24738.html

猜你在找的PHP相关文章