Home > Backend Development > PHP Tutorial > Thinkphp common path usage analysis, thinkphp path usage_PHP tutorial

Thinkphp common path usage analysis, thinkphp path usage_PHP tutorial

WBOY
Release: 2016-07-13 10:12:36
Original
913 people have browsed it

Thinkphp common path usage analysis, thinkphp path usage

This article analyzes the common path usage of thinkphp with examples. Share it with everyone for your reference. The details are as follows:

The tags introduced here mainly include: __root__ __self__ __action__ __url__ __app__ __public__

Suppose the URL of your project homepage is: www.test.com/other/Form

If the current module is: Index

If the current operation is: index

Then the complete URL of the homepage: 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 operation of the path part in the template is as follows:

Copy the code The code is as follows:
//Project public directory
$tmplContent = str_ireplace('../public',APP_PUBLIC_URL,$tmplContent);
//Website public 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);
//Current module address
$tmplContent = str_replace('__URL__',__URL__,$tmplContent);
//Current project operation address
$tmplContent = str_replace('__ACTION__',__ACTION__,$tmplContent);
//Current page operation address
$tmplContent = str_replace('__SELF__',__SELF__,$tmplContent);

I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/920603.htmlTechArticleAnalysis of thinkphp common path usage, thinkphp path usage This article analyzes the common path usage of thinkphp with examples. Share it with everyone for your reference. The details are as follows: The tags introduced here are mainly...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template