On the thinkphp-controller

Source: Internet
Author: User

1. Controller operation

(config) ' action_suffix ' = ' abc ',//Add Controller method suffix to prevent collisions

Public Function Indexabc () {//followed by the ABC suffix

}//url:index will be all right.

2. Internal calls

/*//Internal call

Public Function User() {
$userEvent =new userevent(); Internal modules
$userEvent,use R (); Method
*/

/*//Internal Call
$userEvent =a ('User', 'Event'); Internal modules
$userEvent-user(); Method
*/

}

3. Pre-and post-execution

Pre-execute plus prefix _before
Public Function _before_index () {
Echo ' Front ';
}
Post-execution prefix _after
Public Function _after_index () {
Echo ' after ';
}

4. Multilevel Controller

Allow level two connections
(config)//' Controller_level ' =>2,
When open two level, the level can not be used, do not open two, level two can not be used

Create a second controller in the controller.

5. Jump and return

Public Function User () {

$fiag =true;
if ($flag) {
Jump to
$this->success (' New success ', ' ... /kzhiq/all ');
}
  
else{
Jump to
$this->error (' new failure ');
}
  
}
Public Function All () {
Echo ' WCL ';
}

}

On the thinkphp-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.