This article mainly introduces the thinkphp template assignment and replacement methods, describes two simple methods for template replication in the form of instances, as well as the special string descriptions and usage examples in template replacement, it is a high-frequency technique. if you need it, you can refer to the examples in this article to describe the thinkphp template assignment and replacement methods. Share it with you for your reference. The specific implementation method is as follows:
1. the assignment method in the template:
The code is as follows:
$ This-> assign ('name', 'foot home'); // The first assignment method
$ This-> name = 'jb51 '; // The second dynamic assignment method.
$ This-> display ();
2. Template replacement method:
PUBLIC __: it will be replaced with the Public directory of the current website, usually/thinkphp/PUBLIC/Folder. in public, create a CSS folder and a basic.css file.
: It will be replaced with the current website address (excluding domain names)/thinkphp
/Index. php: the URL address of the current project (excluding domain names)/thinkphp/index. php;
/Index. php: it will be replaced with the URL address (excluding domain names)/thinkphp/index. php/Index of the current group;
/Index. php/Article: it will be replaced with the URL address (excluding domain names)/thinkphp/index. php/Index/index of the current module;
/Index. php/Article/detail: the URL address of the current operation (excluding the domain name)/thinkphp /;
/Php-weizijiaocheng-30878.html: will be replaced with the current page URL
Change template variable rules and modify configuration items
The code is as follows:
'Tmpl _ PARSE_STRING '=> array (// add your own template variable rules
'_ CSS _' =>. '/Public/Css', // specifies the file storage directory
'_ JS _' =>. '/Public/JS ',
),
Call method:
The code is as follows:
Href = '_ CSS _/basic.css' href = '_ JS _/basic.css'
I hope this article will help you with ThinkPHP framework programming.