国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > php框架 > ZendFramework > Zend Framework教程-MVC-Action(Zend_Controller_Action)

Zend Framework教程-MVC-Action(Zend_Controller_Action)

来源:程序员人生   发布时间:2014-02-22 22:01:33 阅读次数:3617次

Controller控制器的大部分工作还是通过内部的Action方法完成的。看看Action的具体定义规则。
基本代码:

    public function indexAction()    {        // action body    }


基本规则:

1.controller的action方法以Action结尾。

2.action名称通常全部是小写,action是区分大小写的。也不要采用特殊字符用常规的英文字母和数字即可。

3.action通常默认会映射到一个html文件,作为action的输出显示页面,扩展名为phtml,该文件根目录默认是应用的/application/views/scripts下。action的html文件对应为controller类名称文件夹/action名称.phtml

例如:IndexController的indexAction对应的phtml文件为application/views/scripts/index/index.phtml

 注意名称大小写问题。



访问action的方法大致如下:

http://域名/index.php/controller名称/action名称/参数列表。

index.php可以省略。

例如:

http://www.localzend.com/

http://www.localzend.com/index

http://www.localzend.com/index/index

默认的访问http://www.localzend.com/是访问的http://www.localzend.com/index/index

默认的访问http://www.localzend.com/index是访问的http://www.localzend.com/index/index


当然可以自己定义路由格式。在后续章节会介绍Zend_Controller_Router



生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生