escape[編碼]
This is used to html escape, url escape, escape single quotes on a
variable not already escaped, hex escape, hexentity or javascript escape.
By default, the variable is html
escaped.
用于html轉(zhuǎn)碼,url轉(zhuǎn)碼,在沒有轉(zhuǎn)碼的變量上轉(zhuǎn)換單引號,十六進制轉(zhuǎn)碼,十六進制美化,或者javascript轉(zhuǎn)碼。默認是html轉(zhuǎn)碼。
Example 5-11. escape
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', "'Stiff Opposition Expected to Casketless Funeral Plan'");
$smarty->display('index.tpl');
index.tpl:
{$articleTitle}
{$articleTitle|escape}
{$articleTitle|escape:"html"} {* escapes & " ' < > *}
{$articleTitle|escape:"htmlall"} {* escapes ALL html entities *}
{$articleTitle|escape:"url"}
{$articleTitle|escape:"quotes"}
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
OUTPUT:
'Stiff Opposition Expected to Casketless Funeral Plan'
'Stiff Opposition Expected to Casketless Funeral Plan'
'Stiff Opposition Expected to Casketless Funeral Plan'
'Stiff Opposition Expected to Casketless Funeral Plan'
%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27
\'Stiff Opposition Expected to Casketless Funeral Plan\'
<a href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">bob@me.net</a>
|
|