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

Home php教程 PHP開發(fā) Zend Framework front-end controller usage example

Zend Framework front-end controller usage example

Jan 06, 2017 am 09:54 AM

The example in this article describes the usage of Zend Framework front-end controller. Share it with everyone for your reference, the details are as follows:

Common methods

1.getInstance()

Function: Used to obtain the front-end controller instance.

The code is as follows:

<?php
$front = Zend_Controller_Front::getInstance();

Executing the above code will create a front-end controller instance.

2.setControllerDirectory()

Function: Used to notify the distributor where to find the action controller action controller class file.

3.getControllerDirectory()

Function: Used to obtain the current location of the controller directory

The code is as follows:

<?php
$front = Zend_Controller_Front::getInstance();
$dire = $front->getControllerDirectory();

Environment accessor method

1.resetInstance()
Function: Clear all current settings

2.(set|get)DefaultControllerName()
Function: Specify another name for the default controller, and get the current value

3.(set|get)DefaultActionName()
Function: Specify another name for the default action, and get the current value

4.(set|get)Request()
Function: Specify the request class or object used in the distribution process, and obtain the current request object

5.(set|get )Router()
Function: Specify the router class or object used in the distribution process, and obtain the current object

6.(set|get)Response()
Function: Specify the router class or object used in the distribution process The response class or object, and getting the current object

Front-end controller parameters

1.setParam(name,name,value)
Function: Set a single parameter value with value A single parameter name

2.setParams(array $params)
Function: Set multiple parameters at once through an associative array

3.getParam($name)
Function: Get a single parameter through the $name identifier

4.getParams()
Function: Get the entire parameter list at one time

5.clearParams()
Function: Clear a parameter (pass Enter a single string), multiple parameters (pass in an array), all parameters (no parameters)

Example:

<?php
require_once &#39;Zend/Controller/Front.php&#39;;    //加載Zend_Controller_Front類
$front = Zend_Controller_Front::getInstance();  //獲取前端控制器實(shí)例
$front->setParam(&#39;name&#39;,&#39;張三&#39;);        //設(shè)定前端控制器參數(shù)
$name = $front->getParam(&#39;name&#39;);        //獲取設(shè)定的參數(shù)
echo $name;
echo "<p>";
$array = array(
  &#39;g_n&#39;=>&#39;聯(lián)想&#39;,
  &#39;g_c&#39;=>&#39;5000&#39;,
  &#39;g_a&#39;=>&#39;北京&#39;,
  &#39;g_p&#39;=>&#39;聯(lián)想集團(tuán)&#39;
);
$front->setParams($array);
$g = $front->getParams();
foreach($g as $k=>$v){
  echo $k."的值為:".$v;
  echo "<p>";
}
$front->clearParams();
$last = $front->getParams();
foreach($last as $k=>$v){
  echo $k."的值為:".$v;
  echo "<p>";
}

The result is:

張三
name的值為:張三
g_n的值為:聯(lián)想
g_c的值為:5000
g_a的值為:北京
g_p的值為:聯(lián)想集團(tuán)

Because the parameters are cleared, no data is output during the second call.

I hope this article will be helpful to everyone’s PHP programming based on the Zend Framework framework.

For more Zend Framework front-end controller usage examples and related articles, please pay attention to the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)