Home > Backend Development > PHP Tutorial > Summary of smarty variable operators_PHP tutorial

Summary of smarty variable operators_PHP tutorial

WBOY
Release: 2016-07-13 10:31:05
Original
891 people have browsed it

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

{insert name="get_time"}

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);

Articles you may be interested in

  • Smarty template variable operator summary
  • Using php functions in smarty templates and how to use multiple functions for one variable in smarty templates
  • Smarty template retained variables summary
  • smarty include file Methods of using variables
  • Smarty loop operation
  • Escape the variables passed in by the user, excerpted from ecshop
  • javascript to get the current position of the mouse (compatible with IE and firefox)
  • Use PHP function memory_get_usage gets the current PHP memory consumption to optimize the performance of the program

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764163.htmlTechArticlesmarty Summary of commonly used variable operators. capitalize [capitalize the first letter] count_characters [count the number of characters] cat [connection string] count_paragraphs [count the number of paragraphs] count_sentences [count...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template