Thinkphp the action is not defined in the URL and can be accessed to the template?

Source: Internet
Author: User
Thinkphp the action is not defined in the URL and can be accessed to the template?

Recently started to touch the framework of thinkphp, but when looking at the company source code, found that the action in the URL does not have a corresponding implementation method in the class.

The empty operation and the empty module in thinkphp, I thought it was done by an empty operation.

Final confirmation Result: There is no module at all, directly the action corresponding template to display.

I just contacted thinkphp don't know why ask God for help


Reply to discussion (solution)

You see the configuration is not enabled in the routing function, the routing function can forge the address, do not know if this is the problem you are experiencing.

You see the configuration is not enabled in the routing function, the routing function can forge the address, do not know if this is the problem you are experiencing.

You see the configuration is not enabled in the routing function, the routing function can forge the address, do not know if this is the problem you are experiencing.


There are no routing rules. I checked the internet, some people say how the template is static, action in the class can not need to define, do not know what reason

The method is automatically detected before the user's custom action is entered
If you do not read the template directly, even the template does not have a report that the method does not exist such errors

The method is automatically detected before the user's custom action is entered
If you do not read the template directly, even the template does not have a report that the method does not exist such errors



Thank you for your explanation, can you provide me with a link to this description on the thinkphp website?


The method is automatically detected before the user's custom action is entered
If you do not read the template directly, even the template does not have a report that the method does not exist such errors



Thank you for your explanation, can you provide me with a link to this description on the thinkphp website?

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



The method is automatically detected before the user's custom action is entered
If you do not read the template directly, even the template does not have a report that the method does not exist such errors



Thank you for your explanation, can you provide me with a link to this description on the thinkphp website?

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



Dude, the link you gave me didn't seem to have the brother (Wander_wind) explaining it.


The method is automatically detected before the user's custom action is entered
If you do not read the template directly, even the template does not have a report that the method does not exist such errors



Thank you for your explanation, can you provide me with a link to this description on the thinkphp website?



This one... Did not carefully read the official, according to its performance can completely reverse the introduction of the principle
If you are interested, you can read the source of TP completely

See thinkphp/library/think/controller.class.php __call method

    /**     * Magic method has a nonexistent operation when executing     * @access public     * @param string $method method name     * @param array $args parameter     * @return Mixed     */public    function __call ($method, $args) {        if (0 = = = strcasecmp ($method, Action_name. C (' Action_suffix ')) {if            (method_exists ($this, ' _empty ')) {                //If the _empty operation defined is called                $this->_empty ($ method, $args);            } ElseIf (File_exists_case ($this->view->parsetemplate ())) {                //check if 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-tolerant technique and does not need to be explained in the user manual

See thinkphp/library/think/controller.class.php __call method

    /**     * Magic method has a nonexistent operation when executing     * @access public     * @param string $method method name     * @param array $args parameter     * @return Mixed     */public    function __call ($method, $args) {        if (0 = = = strcasecmp ($method, Action_name. C (' Action_suffix ')) {if            (method_exists ($this, ' _empty ')) {                //If the _empty operation defined is called                $this->_empty ($ method, $args);            } ElseIf (File_exists_case ($this->view->parsetemplate ())) {                //check if 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-tolerant technique and does not need to be explained in the user manual



Thank you Moderator
  • Related Article

    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.