ThinkPHP template replacement and system constants and application examples tutorial

Source: Internet
Author: User
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.

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.