Can templates be accessed even if action is not defined in thinkphpurl?

Source: Internet
Author: User
Can templates be accessed even if action is not defined in thinkphpurl? Can templates be accessed even if action is not defined in thinkphp url?

I recently started to access the thinkphp framework, but when looking at the company's source code, I found that the action in the url does not have a corresponding implementation method in the class.

In thinkphp, empty operations and empty modules are implemented by empty operations.

Final confirmation result: the template corresponding to the action is directly displayed without passing through the module.

I just got in touch with thinkphp. I don't know why.


Reply to discussion (solution)

Check whether the routing function is enabled in the configuration. the routing function can forge the address. I wonder if this is a problem you are currently encountering.

Check whether the routing function is enabled in the configuration. the routing function can forge the address. I wonder if this is a problem you are currently encountering.

Check whether the routing function is enabled in the configuration. the routing function can forge the address. I wonder if this is a problem you are currently encountering.


No routing rules. I checked it online. some people say that if the template is static, the action can be defined in the class without knowing why.

Before entering the user-defined action, the system automatically checks whether the method exists.
If no template exists, read the template directly. If no template exists, an error such as the method does not exist will be reported.

Before entering the user-defined action, the system automatically checks whether the method exists.
If no template exists, read the template directly. If no template exists, an error such as the method does not exist will be reported.



Thank you for your explanation. can you provide me a link to thinkphp's official website?


Before entering the user-defined action, the system automatically checks whether the method exists.
If no template exists, read the template directly. If no template exists, an error such as the method does not exist will be reported.



Thank you for your explanation. can you provide me a link to thinkphp's official website?

Http://document.thinkphp1.cn/manual_3_2.html#route



Before entering the user-defined action, the system automatically checks whether the method exists.
If no template exists, read the template directly. If no template exists, an error such as the method does not exist will be reported.



Thank you for your explanation. can you provide me a link to thinkphp's official website?

Http://document.thinkphp1.cn/manual_3_2.html#route



Brother, the link you gave does not seem to have explained this brother (wandre_wind ).


Before entering the user-defined action, the system automatically checks whether the method exists.
If no template exists, read the template directly. If no template exists, an error such as the method does not exist will be reported.



Thank you for your explanation. can you provide me a link to thinkphp's official website?



This... I have not carefully read the official documents. based on its performance, I can completely reverse introduce the principle.
If you are interested, read the tp source code.

See ThinkPHP/Library/Think/Controller. class. php _ call method.

/*** Run the * @ access public * @ param string $ method name * @ param array $ args parameter * @ return mixed */public function when the magic method does not exist. _ call ($ method, $ args) {if (0 === strcasecmp ($ method, ACTION_NAME.C ('Action _ SUFFIX ') {if (method_exists ($ this,' _ empty ')) {// if the _ empty operation is defined, $ this-> _ empty ($ method, $ args) is called );} elseif (file_exists_case ($ this-> view-> parseTemplate () {// Check whether there is a default template. if there is a direct output template $ this-> display ();} else {E (L ('_ ERROR_ACTION _'). ':'. ACTION_NAME) ;}} else {E (_ CLASS __. ':'. $ method. L ('_ METHOD_NOT_EXIST _'); return ;}}
This is a fault tolerance technique and does not need to be described in the user manual.

See ThinkPHP/Library/Think/Controller. class. php _ call method.

/*** Run the * @ access public * @ param string $ method name * @ param array $ args parameter * @ return mixed */public function when the magic method does not exist. _ call ($ method, $ args) {if (0 === strcasecmp ($ method, ACTION_NAME.C ('Action _ SUFFIX ') {if (method_exists ($ this,' _ empty ')) {// if the _ empty operation is defined, $ this-> _ empty ($ method, $ args) is called );} elseif (file_exists_case ($ this-> view-> parseTemplate () {// Check whether there is a default template. if there is a direct output template $ this-> display ();} else {E (L ('_ ERROR_ACTION _'). ':'. ACTION_NAME) ;}} else {E (_ CLASS __. ':'. $ method. L ('_ METHOD_NOT_EXIST _'); return ;}}
This is a fault tolerance technique and does not need to be described in the user manual.



Thanks to the moderator

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.