This article mainly introduces ThinkPHP template replacement, system constants, and applications. it is a very important concept. if you need ThinkPHP, you can refer to ThinkPHP.
This article describes ThinkPHP template replacement, system constants, and applications. it is the basic knowledge of ThinkPHP project development and must be well mastered. The details are as follows:
Default Template replacement rules:
/Cms/tpl/Index/Public: it will be replaced with the Public Template directory of the current project, which is usually/project directory/Tpl/default/Public/
/Public: the Public directory of the current website is usually/Public/
/Cms/tpl/Index/: The Template directory that will be replaced with the project is usually/project directory/Tpl/default/
: It will be replaced with the address of the current website (excluding the domain name)
/Index. php: it will be replaced with the URL address of the current project (excluding the domain name)
/Index. php/Article: it will be replaced with the URL address of the current module (excluding the domain name)
/Index. php/Article/detail: it will be replaced with the URL address of the current operation (excluding the domain name)
/Php-weizijiaocheng-55170.html: will be replaced with the current page URL
You can also configure the TMPL_PARSE_STRING value in the project configuration file to customize replacement rules, such:
TMPL_PARSE_STRING => array ('/public' =>'/common ', // change the default/Public replacement rule '_ UPLOAD _' => '/Public/Uploads/', // add a new UPLOAD path replacement rule)
Example:
File path:/Home/Tpl/default/User/index.html. the code is as follows:
Represents the current website URL
/Index. php/Article indicates the URL address of the current module/index. php/User
/Cms/tpl/Index/Public representative/aoli/Tpl/default/Public
/Public indicates the Public file directory of the project/Public
/Cms/tpl/Index/indicates the Template directory of the current project/aoli/Tpl/default/
/Index. php indicates the entry file address of the current project/index. php
/Index. php/Article/detail indicates the current operation address/index. php/User/index
/Php-weizijiaocheng-55170.html represents the current URL/index. php/User/
_ UPLOAD __
File path:/Home/Lib/Action/UserAction. class. php. the code is as follows:
<?php class UserAction extends Action { function index(){ $this->display(); } function add(){ dump($_POST); } }?>
Access path: http: // localhost/index. php/User/index input content, click the Register button to jump to http: // localhost/index. php/User/add and execute the add method in the User module to output the submitted content.
I hope this article will help you with ThinkPHP programming.