Yii Action Method Tips _php Tutorial

Source: Internet
Author: User

Yii Action Method Tips


An action is defined as a method named with the action Word as the prefix. The more advanced way is to define an action class and have the controller instantiate it when it receives the request. This allows the action to be reused, improving the reusability.

1, define an action class, the basic format is as follows:

Class Updateaction extends Caction{public function run () {//... Logical code ...}}

2, use the action class: In order to let the controller notice this action, we need to cover the Controller class of the actions () method as follows:

Class Postcontroller extends Ccontroller{public function actions () {return array (//using the Application Folder/controllers/post/ updateaction.php "File class to handle the edit action ' edit ' = ' application.controllers.post.UpdateAction ',);}}

As shown above, we used the path alias application.controllers.post.UpdateAction to specify the action class file as protected/controllers/post/updateaction.php

By writing class-based actions, we can organize the application into the style of the module.

Articles you may be interested in

    • Eight classic tricks for Linux OS applications
    • The action parameter binding processing of YII controller
    • Yii database Add, modify, delete related Operations summary
    • Ten tips for accelerating Win7 system optimization
    • Improve database performance uncover SQL optimization tips
    • Methods and techniques for studying PHP open-stream code
    • A summary of query techniques in thinkphp
    • The summary of Yii database query operation

http://www.bkjia.com/PHPjc/983633.html www.bkjia.com true http://www.bkjia.com/PHPjc/983633.html techarticle Yii action method Skill action refers to a method that is defined as a prefix named with an action word. The more advanced way is to define an action class and have the controller make the request when it receives ...

  • 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.