Yii action method tip _ PHP Tutorial

Source: Internet
Author: User
Yii action methods and techniques. Yii action method skill action refers to a method defined as a prefix named with action words. The more advanced method is to define a category class and let the controller send the Yii action method when receiving the request.

An action is defined as a method named with the action word as the prefix. The more advanced method is to define a handler class and let the controller instantiate the class when receiving the request. This allows the action to be reused, improving the reusability.

1. define a category. The basic format is as follows:

Class UpdateAction extends CAction {public function run () {//... logic code ...}}

2. use the actions class: to let the controller notice this action, we need to overwrite the actions () method of the controller class in the following way:

Class PostController extends CController {public function actions () {return array (// use "application folder/controllers/post/UpdateAction. php "file class to process the edit action 'edit' => 'application. controllers. post. updateaction ',);}}

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

By writing class-based actions, we can organize applications into a module style.

Articles you may be interested in
  • Eight typical Linux operating system applications
  • Yii controller action parameter binding
  • Yii database addition, modification, and deletion operations summary
  • Top 10 tips for accelerating Win7 system optimization
  • Improve database performance Secret SQL optimization skills
  • Methods and techniques for studying php open source code
  • Summary of query techniques in ThinkPHP
  • Yii database query operation summary

Http://www.bkjia.com/PHPjc/983633.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/983633.htmlTechArticleYii action method tip action is defined as a method named with action words as prefix. The more advanced way is to define a handler class and let the controller...

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.