国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

Zend Framework教程之MVC框架的Controller用法分析

2024-05-04 23:43:41
字體:
供稿:網(wǎng)友
這篇文章主要介紹了Zend Framework教程之MVC框架的Controller用法,簡(jiǎn)單分析了MVC框架的基本結(jié)構(gòu)與Controller控制器的簡(jiǎn)單使用方法,需要的朋友可以參考下
 

本文講述了Zend Framework教程之MVC框架的Controller用法。分享給大家供大家參考,具體如下:

這里簡(jiǎn)單講講MVC模式中Controller的基本使用方法。

基本使用實(shí)例:

root@coder-671T-M:/www/zf_demo1/application# tree.
├── Bootstrap.php
├── configs
│   └── application.ini
├── controllers
│   ├── ErrorController.php
│   └── IndexController.php
├── models
└── views
    ├── helpers
    └── scripts
        ├── error
        │   └── error.phtml
        └── index
            └── index.phtml

IndexController.php

<?phpclass IndexController extends Zend_Controller_Action{  public function init()  {    /* Initialize action controller here */  }  public function indexAction()  {    // action body  }}

規(guī)則:

1.通常Controller存放在應(yīng)用的/application/controllers目錄下。
可以通過以下方式自定義路徑:

Zend_Controller_Front::run('/path/to/app/controllers');

或者通過以下方式自定義路徑:

// Set the default controller directory:$front->setControllerDirectory('../application/controllers');// Set several module directories at once:$front->setControllerDirectory(array(  'default' => '../application/controllers',  'blog'  => '../modules/blog/controllers',  'news'  => '../modules/news/controllers',));// Add a 'foo' module directory:$front->addControllerDirectory('../modules/foo/controllers', 'foo');

默認(rèn)情況下存放在默認(rèn)的目錄即可。

2.文件名和類名相同
3.類名以Controller結(jié)尾,并且繼承Zend_Controller_Action
4.類名第一個(gè)字母大寫,遵守駝峰風(fēng)格。利潤(rùn)NewsListControlle
4.文件名以Controller.php結(jié)尾
5.Controller的初始化工作可以在init方法中完成

public function init(){}
 


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到PHP教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 海安县| 广东省| 新密市| 信宜市| 彝良县| 美姑县| 新兴县| 怀柔区| 怀化市| 泸州市| 礼泉县| 石楼县| 德令哈市| 柘城县| 京山县| 灌南县| 岗巴县| 宾川县| 蕉岭县| 鄂托克前旗| 华池县| 讷河市| 小金县| 南开区| 长垣县| 扶绥县| 鹤庆县| 临泽县| 永济市| 花莲县| 上虞市| 清新县| 黄浦区| 保亭| 大埔区| 嘉黎县| 通化县| 贵南县| 中方县| 泌阳县| 凤冈县|