smarty Summary of commonly used variable operators.
capitalize [capitalize]
count_characters [Count the number of characters]
cat [connection string]
count_paragraphs [Count number of paragraphs]
count_sentences [Count sentences]
count_words [Count the number of words]
date_format [time format]
default [default]
escape [transcoding]
indent[indent]
lower[lowercase]
nl2br[Line breaks replaced with
]
regex_replace[regular replacement]
replace[replace]
spacify[insert blank]
string_format[string format]
strip[remove (excess spaces)]
strip_tags[remove html tags]
truncate[interception]
upper[uppercase]
wordwrap[line width constraint]
{$cook_hotelArr|count} [Maximum subscript of array]
{section name=s loop=$stu}
{$stu[s].name}
{sectionelse}
No content
{/section}
$smarty->cache_dir="/caches/"; //Cache directory
$smarty->caching=true; //Enable caching. When it is flase, the cache will be invalid
$smarty->cache_lifetime=60; //Cache time
$smarty->display("cache.tpl",cache_id); //Create a cache with ID
$smarty->clear_all_cache(); //Clear all caches
$smarty->clear_cache("index.htm"); //Clear the cache of index.tpl
$smarty->clear_cache("index.htm",cache_id); //Clear the cache of the specified id
index.htm
index.php
function insert_get_time(){
return date("Y-m-d H:m:s");
}
Literal data will be treated as text, and the template will ignore all character information inside it. This feature is used to display javascript scripts that may contain character information such as braces
{literal}
{/literal}
The leading and trailing spaces and carriage returns of the data in the strip tag. This ensures that the template is easy to understand and you don’t have to worry about extra spaces causing problems. Generally placed at the beginning and end of HTML code
Cache processing of files under the same domain name
For example, the same file in a sub-site can be solved by multiple parameters when loading
$smarty->display("hotel.htm",$cityId);