Zend Framework Dispatcher Usage Example _php instance

Source: Internet
Author: User

The examples in this article describe the Zend Framework dispatcher usage. Share to everyone for your reference, specific as follows:

Distribution is the process of obtaining the requested object, extracting the module name, controller name, action name, and optional parameters, and then instantiating the controller and invoking the action.

If the module, controller, or action is not found, the default value is used.

The Zend_controller_dispatcher_standard class specifies that the default value for each controller and action is index, and the module defaults to default.

This class allows developers to change the default value setting through the Setdefaultcontroller () method, the SetDefaultAction () method, and the Setdefaultmodule () method.

_forward ()

function: Call the method in any action, and pass in the action, controller, module, and optional parameters to enter the new action.

Case:

<?php Public
function fooaction () {  //define action
  //Go to the current controller and other actions in the module
  $this->_forward (' bar ', NULL, Null,array (' Baz ' => ' bogus '))//First argument, table action, second argument, table controller, third parameter represents module
} public
function Baraction () {  //
  foocontroller::bazaction ()
  $this->_forward (' Baz ', ' foo ', Null,array (' Baz '), which defines the action//move to the other controller of the current module. > ' bogus ');
}
Public Function bazaction () {
  //go to other controllers, actions in other modules, foo_barcontroller::bazaction ()
  $this->_forward (' Baz ', ' Bar ', ' foo ', Array (' Baz ' => ' bogus ');
}

More interested in Zend related content readers can view the site topics: "The introduction of the Zend Framework frame", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Course", "PHP object-oriented Programming Program , "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design based on the Zend Framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.