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.