How does one implement the display () method in the thinkphp controller?

Source: Internet
Author: User
Thinkphp controller display () method implementation principle what is & nbsp; display () in the method, you can automatically search for the template file & nbsp based on the called method name without entering the parameter. how does this happen? How does it obtain the display () in the thinkphp controller of the called method name () principle of implementation
What is the implementation principle of the display () method in the thinkphp controller?
In the display () method, you can automatically search for template files based on the called method name without entering parameters.
How is this implemented? How does it obtain the name of the called method?

We would like to discuss with you how to write code or key methods and ideas that can implement such a function.

------ Solution --------------------
Search for the source code and you will not be able to read it.
PHP code
Define ('Module _ name', self: getModule (C ('Var _ module'); define ('Action _ name', self :: getAction (C ('Var _ action '))); /** + ---------------------- * obtain the actual module name + ------------------------ * @ access private + ------------------------ * @ return string + -------------------- */static private function getModule ($ var) {$ module = (! Empty ($ _ GET [$ var])? $ _ GET [$ var]: C ('default _ module'); if (C ('URL _ CASE_INSENSITIVE ')) {// The URL address is case-insensitive. define ('P _ MODULE_NAME ', strtolower ($ module); // The intelligent identification method index. php/user_type/index/identifies the UserTypeAction module $ module = ucfirst (parse_name (P_MODULE_NAME, 1);} unset ($ _ GET [$ var]); return $ module ;} /** + ---------------------- * get the actual operation name + ---------------------- * @ access private + ------------------------ * @ return string + --- ------------------- */Static private function getAction ($ var) {$ action =! Empty ($ _ POST [$ var])? $ _ POST [$ var]: (! Empty ($ _ GET [$ var])? $ _ GET [$ var]: C ('default _ action'); unset ($ _ POST [$ var], $ _ GET [$ var]); return C ('URL _ CASE_INSENSITIVE ')? Strtolower ($ action): $ action ;}

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.