Thinkphp URL mode and example

Source: Internet
Author: User

 
 
<? The URL modes supported by PHP // thinkphp include normal mode, pathinfo mode, rewrite mode, and compatibility mode, and provide route support. The default value is pathinfo. // For example, the URL in normal mode is: // http: // localhost/appname/index. php? M = modulename & A = actionname & id = 1 // 1. in pathinfo mode, the URL is // http: // localhost/appname/index. PHP/modulename/actionname/ID/1 // The pathinfo mode does not affect the previous programming methods, and the value passing through get and post methods is still valid because the system will automatically process pathinfo, for example, the value of ID in the URL above can be obtained through $ _ Get ['id. // 2. if the rewrite mode is used, the URL can be: // http: // localhost/appname/modulename/actionname/ID/1 // For example, if the MyApp project generated above is accessed through the following url: // http: // localhost/MyApp // In fact, it is to locate the index operation of the index module of the MyApp project, because the system will execute the default module and operation when no module or operation is specified, in thinkphp's conventional configuration, the index module and index operations are involved. Therefore, the following URL is the same as the above result: // http: // localhost/MyApp/index. PHP/index // use the project configuration parameters to change the default configuration. // The system also supports the grouping mode and URL routing functions, which can bring different URL experiences. // Suppose I write in TP/index. phpProgram Call the class indexaction extends action {Public Function Index () {// default access controller method of TP. You can set echo 'HTTP: // blog.csdn.net/ljfbest is my blog '; // enter http: // localhost/TP/in the address bar, and the result will be output because the system will execute the default module and operation when no module or operation is specified, in thinkphp's conventional configuration, the index module and the index operation} public function show () {// by default, a calls echo 'url routing mode test '; echo $ _ Get ['id']; // enter http: // localhost/TP/index in the address bar. PHP? A = show & id = 3 (called by a by default) Press enter to change the address bar to http: // localhost/TP/index. PHP/index/show/ID/3 Output URL routing mode test 3 }}?>


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.