PHP头条
热点:

yii框架如何配置默认controller与action


本文介绍了yii框架中配置默认controller和action的方法,分享一个设置默认controller和action的例子,有学习yii的朋友可以参考下,个人感觉还不错的。

在yii框架中,设置默认 controller 在/protected/config/main.php添加配置,具体代码如下:

<?php
return array(
	'name'=>'Auto',
	'defaultController'=>'auto',
	......

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

在yii框架中,设置默认 action 在刚才定义的 AutoController.php 中设置,具体代码如下:

<?php
class AutoController extends CController{
    public $defaultAction='test';
    public function actionTest(){
        ...
    }
    ...

此时访问 xxxx/index.php,会默认转到 xxxx/index.php?r=auto/test,表示设置成功。

您可能感兴趣的文章

  • 网页缓存控制 Cache-control 常见的取值有private、no-cache、max-age、must-revalidate 介绍
  • yii框架目录结构详细分析说明
  • PHP解决网址URL编码问题的函数urlencode()、urldecode()、rawurlencode()、rawurldecode()
  • yii框架缓存知识总结
  • 由于其配置信息(注册表中的)不完整或已损坏,Windows 无法启动这个硬件设备。 (代码 19)解决办法
  • php提示Call to undefined function curl_init() 错误的解决办法
  • jquery操作cookie,jquery读取cookie,jquery设置cookie,jquery删除cookie
  • 如何去除codeIgniter开发的网站url里面的index.php字符串

www.phpzy.comtrue/php/1893.htmlTechArticleyii框架如何配置默认controller与action 本文介绍了yii框架中配置默认controller和action的方法,分享一个设置默认controller和action的例子,有学习yii的朋友可以参考下,个人感觉还不错的。 在...

相关文章

相关频道:

PHP之友评论

今天推荐