国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁 php教程 PHP開發(fā) Zend Framework教程之MVC框架的Controller用法分析

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

Jan 05, 2017 am 11:13 AM

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

這里簡單講講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目錄下。
可以通過以下方式自定義路徑:

Zend_Controller_Front::run(&#39;/path/to/app/controllers&#39;);

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

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

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

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

public function init()
{
}

? ?

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

更多Zend Framework教程之MVC框架的Controller用法分析相關(guān)文章請關(guān)注PHP中文網(wǎng)!

本站聲明
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅(qū)動(dòng)的應(yīng)用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用于從照片中去除衣服的在線人工智能工具。

Clothoff.io

Clothoff.io

AI脫衣機(jī)

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智能換臉工具輕松在任何視頻中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的代碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

功能強(qiáng)大的PHP集成開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級(jí)代碼編輯軟件(SublimeText3)