PHP smarty Template engine configuration and testing
Smarty Introduction
Smarty is a php template used to write a template engine, it provides a separation of logic and external content, in brief, the purpose is to use a PHP programmer with the Art
PHP's Smarty template engine
PHP is an embedded HTML scripting language, in order to separate the HTML and PHP code, the so-called logical layer and the presentation layer, which is the purpose of the template engine. In order to achieve this
This example describes the Smarty template engine caching mechanism. Share to everyone for your reference, specific as follows:
First of all, smarty caching and compiling, this is two different concepts, the compiler is started by default, and the
Thinkphp supports a variety of PHP template engines, which can be configured according to individual needs.Below we take Smarty template engine as an example, to everybody said the specific operation Flow!
First go to smarty official online
Original address: Google's webpage snapshot
--------
smarty Template Engine The emergence of XSS vulnerability and the prevention of sharing the situation
Simply put, when using template variables to output source code, ignore the URL, HTML or JS
Smarty3 Day 1 by Feihong Ying ~ 21:46:38
1. What is smarty?Smarty is a template engine written in PHP. It is designed to separate PHP code from HTML code,This allows PHP programmers to focus only on the compilation of PHP code, while webpage artists
MVC is a great idea in the development, so that the development code has a clearer level, so that the code is divided into three layers of each job, whether it is the writing of code and later reading and maintenance, has provided a great
The usage of Smarty-related considerations and several ways to share access variables, you can refer to the need of friends. $ Tpl = new Smarty (); // create a new smarty object. what I use is
Smarty-1, 3.1.6Version
1. set the path to the smarty
The usage of Smarty-related considerations and several ways to share access variables, you can refer to the need of friends.
The usage of Smarty-related considerations and several ways to share access variables, you can refer to the need of friends.
$ Tpl = new Smarty (); // create a new smarty object. What I use isSmarty-1, 3.1.6Version1. Set the path to the smarty template $ tpl->SetTemplateDir ()By defaultTemplates2. Set the path for compiling the smarty template $ tpl->SetCompileDir ()By
The usage of Smarty-related considerations and several ways to share access variables, you can refer to the need of friends. $ Tpl = new Smarty (); // create a new smarty object. what I use is
Smarty-1, 3.1.6Version
1. set the path to the smarty
Use the Smarty 4: custom variable mediation in PHP. There are many text processing functions in PHP. you can use the function to process the text to be processed, and then call assign () in the Smarty template engine to assign values to the variable,
$TPL =new Smarty ();//Create a new Smarty object, I use the
Smarty-3.1.6Version
1. Set the Smarty template path $tpl->
Settemplatedir (); By default
templates2. Set the Smarty template compilation path $tpl->
Setcompiledir (); By default
Templates_c3
1. Smarty cache Configuration:$ Smarty-> cache-dir = "directory name"; // create a cache directory name$ Smarty-> caching = true; // enable cache. If it is false, the cache is invalid.$ Smarty-> cache_lifetime = 60; // cache time, in seconds2. Use
Common 20 variable operators in smarty * use Syntax: {variable name | Operator :}* Capitalize --- uppercase letters* Count_characters --- calculates the number of characters* Cat --- connection string* Count_paragraphs --- calculate the number of
Common 20 variable operators in smarty * use Syntax: {variable name | Operator :}
* Capitalize --- uppercase letters
* Count_characters --- calculates the number of characters
* Cat --- connection string
* Count_paragraphs --- calculate the number
In the foreach loop statement structure of the smarty template engineIterationAndTotalDifferences:
Total displays the total number of times of loop execution.
Iteration displaysCurrentNumber of cycles executed
Therefore, if you want
Smarty Common 20 variable operators * Use syntax: {variable name | operator:}
* Capitalize---initial capital letter
* Count_characters---Count of characters
* Cat---connection string
* Count_paragraphs---Calculation of the number of paragraphs
*
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.