Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Application of variables and variable modifiers in smarty template engine

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "smarty template engine variables and variable modifier example application", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "smarty template engine variables and variable modifier example application" it!

This paper gives an example of the application of smarty variable and variable modifier. Share it with you for your reference. The details are as follows:

Template file: temp.htm:

The copy code is as follows:

{config_load file= "foo.conf"} {$name.na1 | cat:$name ['na2']} {$name [' na1'] | cat:' and'| cat:$name.na2} {$na} {/ foreach} {$dog- > leee ()} {$dog- > name} {literal} function foobar {alert ('foobarring');} {/ literal} {# pageTitle#} dosomething pot {$smarty.server.SERVER_NAME} {$str | count_words}-constant-

{$smarty.now} {$smarty.const.MY_CONST} {$smarty.current_dir} {$smarty.version} {$smarty.ldelim | cat:$smarty.rdelim} {$smarty.now | date_format:$config} {$yesterday | date_format:'Y-m-d'} {$string | default:'default variable modifier: smarty Learning'} {$str1 | escape:'html'} {$str2 | escape:'mail'}

{$str1 | indent | upper}

{$str1 | nl2br} {$str1 | regex_replace: "/ @\ d {3} /": "ABC"} {$str1 | replace: "sina"} {$str1 | spacify} {$number | string_format: "% .2f"} {$number | string_format: "% d"} {$str3 | strip: "|"} remove the characters contained in between: {$str3 | truncate:10: "...": true} wrap by length: {$str3 | wordwrap:30: ""} {append var='name' value= "Bob" index= "first"} {append var='name' value= "John" index= "last"} {$name.last} {foreach from=$family item=home} {foreach from=$home item=person} {/ foreach} {/ foreach} {$family [1] .girl} {assign var= "name" value= "Zhang Sanfeng" php file: index.php copy code is as follows:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report