Smarty Variable operator Summary _php tutorial

Source: Internet
Author: User
Tags smarty template
Summary of variable operators commonly used by Smarty.

Capitalize [First letter capitalization]
Count_characters [Count of characters]
Cat [Connection string]
Count_paragraphs [Count of paragraphs]
Count_sentences [Count of sentences]
Count_words [Count of words]
Date_format [Time format]
default [Defaults]
Escape [Transcode]
indent[Indent]
lower[Lowercase]
nl2br[newline character replaced by
]
regex_replace[Regular Replacement]
replace[Replace]
spacify[intervening spaces]
string_format[string Formatting]
strip[removal (extra spaces)]
strip_tags[Remove HTML tags]
Truncate[Intercept]
Upper[Caps]
wordwrap[line width constraint]
{$cook _hotelarr|count} [Array Max subscript]

{section name=s loop= $stu}
{$stu [S].name}
{Sectionelse}
No content
{/section}

$smarty->cache_dir= "/caches/"; Cache Directory
$smarty->caching=true; Cache is turned on, flase cache is 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 INDEX.TPL cache
$smarty->clear_cache ("index.htm", cache_id); Clears the cache for the specified ID

Index.htm

{Insert Name= "Get_time"}

index.php

function Insert_get_time () {
Return Date ("y-m-d h:m:s");
}

The literal data is treated as text, and the template ignores all character information inside it. This feature is used to display JavaScript scripts that may contain character information, such as curly braces

{literal}

{/literal}

Strip the leading and trailing spaces and carriage returns of the data in the tag. This ensures that the template is easy to understand and does not cause problems with unnecessary whitespace. Usually put in the beginning and end of HTML code

File cache processing under the same domain name

such as the station of the same file, loading multiple parameters can be resolved

$smarty->display ("hotel.htm", $cityId);

Articles you may be interested in

    • Smarty Template Variable operator summary
    • Use PHP functions in Smarty Templates and how to use multiple functions for a variable in a smarty template
    • Smarty Template Retention Variables Summary
    • Smarty include file methods for using variables
    • Smarty Loop operation
    • Escaping user-passed variables, from Ecshop
    • JavaScript gets the current position of the mouse (compatible with IE and Firefox)
    • Use PHP function memory_get_usage to get the current PHP memory consumption to achieve program performance optimization

http://www.bkjia.com/PHPjc/764163.html www.bkjia.com true http://www.bkjia.com/PHPjc/764163.html techarticle Summary of variable operators commonly used by Smarty. Capitalize [capitalize] count_characters [count characters] cat [connection string] count_paragraphs [Count of paragraphs] count_sentences [count ...

  • Related Article

    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.