escape鍙敤浜庡皢鍙橀噺缂栫爜鎴栬浆鎹㈡垚
html,
url, 鍗曞紩鍙,
鍗佸叚杩涘埗, 鍗佸叚杩涘埗瀹炰綋,
javascript 鍜 鐢甸偖鍦板潃銆
榛樿鏄細html銆
| 鍙傛暟椤哄簭 | 绫诲瀷 | 蹇呴夊弬鏁 | 鍏佽鍙栧 | 榛樿鍊 | 璇存槑 |
|---|---|---|---|---|---|
| 1 | string | No |
html, htmlall,
url,
urlpathinfo, 鍗曞紩鍙,
鍗佸叚杩涘埗, 鍗佸叚杩涘埗瀹炰綋,
javascript, 鐢甸偖鍦板潃
|
html |
杩欐槸escape杞崲鍚庣殑鏍煎紡 |
| 2 | string | No |
ISO-8859-1, UTF-8,
鍜屽叾浠
htmlentities()鏀寔鐨勫瓧绗﹂泦
|
UTF-8 |
浼犻掔粰htmlentities()鐨勫瓧绗﹂泦绫诲瀷 |
| 3 | boolean | No | FALSE |
TRUE |
涓ゆ杞崲瀹炰綋锛& 鍒 & (浠呭湪 html 鍜 htmlall 浣跨敤) |
Example聽5.10.聽escape
<?php
$smarty->assign('articleTitle',
"'Stiff Opposition Expected to Casketless Funeral Plan'"
);
$smarty->assign('EmailAddress','smarty@example.com');
?>
涓嬮潰鏄escape鐨勪緥瀛愬拰杈撳嚭锛
{$articleTitle}
'Stiff Opposition Expected to Casketless Funeral Plan'
{$articleTitle|escape}
'Stiff Opposition Expected to Casketless Funeral Plan'
{$articleTitle|escape:'html'} {* escapes & " ' < > *}
'Stiff Opposition Expected to Casketless Funeral Plan'
{$articleTitle|escape:'htmlall'} {* escapes ALL html entities *}
'Stiff Opposition Expected to Casketless Funeral Plan'
<a href="?title={$articleTitle|escape:'url'}">click here</a>
<a
href="?title=%27Stiff%20Opposition%20Expected%20to%20Casketless%20Funeral%20Plan%27">click here</a>
{$articleTitle|escape:'quotes'}
\'Stiff Opposition Expected to Casketless Funeral Plan\'
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
{$EmailAddress|escape:'mail'} {* this converts to email to text *}
<a href="mailto:%62%6f%..snip..%65%74">bob..snip..et</a>
{'mail@example.com'|escape:'mail'}
smarty [AT] example [DOT] com
Example聽5.11.聽escape鐨勫彟涓涓緥瀛
{* "rewind"鍙傛暟鏄綋鍓峌RL鍦板潃 *}
<a href="$my_path?page=foo&rewind=$my_uri|urlencode}">click here</a>
杩欎釜鏂规硶寰堥傚悎鐢ㄥ湪鐢甸偖鍦板潃涓婏紝鍙﹀鍙互鍙傝
{mailto}
{* 鐢甸偖鍦板潃缂栫爜 *}
<a href="mailto:{$EmailAddress|escape:'hex'}">{$EmailAddress|escape:'mail'}</a>
鍙傝
Smarty缂栬瘧杞崲,
{mailto}
鍜
娣锋穯鐢甸偖鍦板潃銆
