欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2016年03月07日 11:58:33   作者:coder  
這篇文章主要介紹了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

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

規(guī)則:

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

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

或者通過(guò)以下方式自定義路徑:

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

public function init()
{
}

更多關(guān)于zend相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《Zend FrameWork框架入門(mén)教程》、《php優(yōu)秀開(kāi)發(fā)框架總結(jié)》、《Yii框架入門(mén)及常用技巧總結(jié)》、《ThinkPHP入門(mén)教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《php+mysql數(shù)據(jù)庫(kù)操作入門(mén)教程》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論