Common thinkphp path usage analysis _ php instance

Source: Internet
Author: User
Refer to the examples in this article to analyze the common thinkphp path usage. Share it with you for your reference. The details are as follows:

The labels described here mainly include: _ root _ self _ action _ url _ app _ public __

Assume that the Homepage URL of your project is www.test.com/other/Form.

If the current module is: Index

If the current operation is: index

Then the home page complete URL: http://www.test.com/other/Form/index.php/Index/index

1:/other/thinkphp/mydemo

Php-weizijiaocheng-30764.html:/other/thinkphp/mydemo/Form/index. php

3/index. php/Article/detail:/other/thinkphp/mydemo/Form/index. php/Index/index

4/index. php/Article:/other/thinkphp/mydemo/Form/index. php/Index

5/index. php:/other/thinkphp/mydemo/Form/index. php

6/Public:/other/thinkphp/mydemo/Public

7 ../public (case-insensitive):/other/thinkphp/mydemo/Form/Tpl/default/Public

8 APP_PUBLIC_URL:/other/thinkphp/mydemo/Form/Tpl/default/Public

9 WEB_PUBLIC_URL:/other/thinkphp/mydemo/Public

The path operations in the template are as follows:

The code is as follows:

// Project Public Directory
$ TmplContent = str_ireplace ('../public', APP_PUBLIC_URL, $ tmplContent );
// Public website directory
$ TmplContent = str_replace ('/public', WEB_PUBLIC_URL, $ tmplContent );
// Website root directory
$ TmplContent = str_replace ('', $ tmplContent );
// Current project address
$ TmplContent = str_replace ('/index. php',/index. php, $ tmplContent );
// Address of the current module
$ TmplContent = str_replace ('/index. php/article',/index. php/Article, $ tmplContent );
// Operation address of the current project
$ TmplContent = str_replace ('/index. php/Article/detail',/index. php/Article/detail, $ tmplContent );
// Operation address on the current page
$ TmplContent = str_replace ('/php-weizijiaocheng-30764.html',/php-weizijiaocheng-30764.html, $ tmplContent );

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.