Use of zendframework init ()-PHP source code

Source: Internet
Author: User
Php code for init () of zendframework:

/* First, let's take a look at the execution sequence of the class constructor. next we will introduce my code structure; */class Action extends Zend_Controller_Action {} class IndexController extends Action {} class BlogController extends Action {}/* at the beginning I want to use constructors, as shown below: */class Action extends Zend_Controller_Action {public function _ construct () {echo 'test' ;}}/* but an error occurred later. The final cause was that the constructor in Zend_Controller_Action was not called. Read the source code of Zend_Controller_Action and find that the 123 line constructor calls the function $ this-> init (). Therefore, I want to refactor this function in Action so that the init () function can be called every time. Finally: */class Action extends Zend_Controller_Action {public function init () {echo 'test' ;}}/*. every controller will execute this function. This technique is very practical! Finally, we will remind you that during each execution, the internal code of the Controller's initialization function init () is first executed, and then the corresponding code is executed according to the corresponding Action () Selected */

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.