Common thinkphp path Usage Analysis and thinkphp path usage

Source: Internet
Author: User

Common thinkphp path Usage Analysis and thinkphp path usage

This document analyzes 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 _ ROOT __:/other/thinkphp/mydemo

2 _ SELF __:/other/thinkphp/mydemo/Form/index. php

3 _ ACTION __:/other/thinkphp/mydemo/Form/index. php/Index/index

4 _ URL __:/other/thinkphp/mydemo/Form/index. php/Index

5 _ APP __:/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:
Copy codeThe 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 ('_ ROOT _' ,__ ROOT __, $ tmplContent );
// Current project address
$ TmplContent = str_replace ('_ APP _' ,__ APP __, $ tmplContent );
// Address of the current Module
$ TmplContent = str_replace ('_ URL _' ,__ URL __, $ tmplContent );
// Operation address of the current project
$ TmplContent = str_replace ('_ ACTION _' ,__ ACTION __, $ tmplContent );
// Operation address on the current page
$ TmplContent = str_replace ('_ SELF _' ,__ SELF __, $ tmplContent );

I hope this article will help you design PHP programs based on the ThinkPHP framework.

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.