THINK URL Routing in PHP

Source: Internet
Author: User
Thinkphp inside will be based on the current? URL to parse the modules and actions to be performed. The return analysis work is implemented by the URL scheduler, the official built-in dispatcher class to complete the schedule. In the dispatcher scheduler, it is based on the
Http://domainName/appName/moduleName/actionName/params
To get the currently required projects (APPNAME), modules (ModuleName) and Operations (ActionName), under certain circumstances, AppName can be unwanted (usually the homepage of the site, because the project name can be specified in the portal file, in which case AppName will be replaced by the import file), in addition to different URL mode settings system will be different intelligent identification.

In fact, the index operation of the index module of the MyApp project is located, because the system executes the default module and operation when the module and operation are not specified, which is the index module and the index operation in the custom configuration of thinkphp. So the following URLs and the above results are the same:

http://localhost/myApp/index.php/Index/index/

With the project configuration parameters, we can change this default configuration.

The system also supports teaming mode and URL routing, which can bring different experiences of URLs.

Analysis of the execution process of the first instance in thinkphp:

First the program entry is the index.php file under MyApp, where require (Think_path. " /thinkphp.php ") is a call to thinkphp.php that contains the commonly used configuration debugging information, then the program will be executed from App::run (), start execution, find the required class, the related file is the default Lib/action directory under the class you declared, Because thinkphp is judged by the name of the class, if you write a class then the format should be: **.class.php format. If the related class is found, the index () function in the class is not specified by default.

The URL pass for the above procedure is: Http://localhost/Myapp/index.php/index/index

Where index.php is the entry file, then index is the class of the index name you defined, and the last index is the index method in the index class you defined.

  • 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.