本文講述了Zend Framework教學(xué)之MVC架構(gòu)的Controller用法。分享給大家參考,具體如下:
這裡簡單講講MVC模式中Controller的基本使用方法。
基本使用實(shí)例:
root@coder-671T-M:/www/zf_demo1/application# tree.
├── Bootstrap.php
├── configs
│?
│?? ├── ErrorController.php
│?? └── IndexController.php
├── models
└── views
??├── 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 } }? ?
/T樂
7.phpZend_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');
? ?
public function init() { }? ? 2.檔案名稱和類別名稱相同
3.類別名稱以Controller結(jié)尾,並且繼承Zend_Controller_Action
4.類別名稱第一個字母大寫,遵守駝峰風(fēng)格。利潤NewsListControlle4.檔名以Controller.php結(jié)尾
5.Controller的初始化工作可以在init方法中完成
rrreee
? ?
本網(wǎng)站聲明
本文內(nèi)容由網(wǎng)友自願投稿,版權(quán)歸原作者所有。本站不承擔(dān)相應(yīng)的法律責(zé)任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請聯(lián)絡(luò)admin@php.cn

熱AI工具

Undress AI Tool
免費(fèi)脫衣圖片

Undresser.AI Undress
人工智慧驅(qū)動的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費(fèi)的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章
如何修復(fù)KB5060533無法在Windows 10中安裝?
4 週前
By DDD
沙丘:覺醒 - 在哪裡獲得絕緣織物
3 週前
By Jack chen
Gmail登錄:如何註冊,登錄或登錄Gmail -Minitool
1 個月前
By Jack chen
如何修復(fù)KB5060999無法在Windows 11中安裝?
3 週前
By DDD
污染的公會指南:阿瓦隆的淪陷
4 週前
By Jack chen

熱工具

記事本++7.3.1
好用且免費(fèi)的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強(qiáng)大的PHP整合開發(fā)環(huán)境

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

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)
