Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 09:06:33
Original
961 people have browsed it

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

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

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

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

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

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

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

此时访问 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字符串
Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!