thinkphp template Assignment and substitution example brief _php instance

Source: Internet
Author: User

This example describes the thinkphp template assignment and substitution method. Share to everyone for your reference. The implementation methods are as follows:

1. Assignment methods in the template:

Copy Code code as follows:
$this->assign (' name ', ' cloud-dwelling community '); The first method of assignment
$this->name= ' jb51 '; the second method of dynamic assignment
$this->display ();

2. Template Replacement Method:

PUBLIC__: will be replaced with the public directory of the current Web site, usually/thinkphp/public/, create a CSS folder and create a basic.css file

__ROOT__: Replace the address of the current Web site (excluding the domain name)/thinkphp

__APP__: Will replace the current project with the URL address (excluding domain name)/thinkphp/index.php;

__GROUP__: Will replace the current group of URL address (excluding domain name)/thinkphp/index.php/index;

__URL__: Will replace the current module's URL address (excluding domain name)/thinkphp/index.php/index/index;

__ACTION__: Will replace the current operation of the URL address (excluding domain name)/thinkphp/;

__SELF__: Replaces the current page URL

Replace the template variable rule, modify the configuration item

Copy Code code as follows:
' Tmpl_parse_string ' =>array (///Add your own template variable rules
' __css__ ' =>__root__. ' /public/css ',//Specify file storage directory
' __js__ ' =>__root__. ' /public/js ',
),

Call Method:
Copy Code code as follows:
href= ' __css__/basic.css ' href= ' __js__/basic.css '

I hope this article will be helpful to everyone's thinkphp framework program design.

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.