escape
パラメータの位置 | 型? | 必須 | 有効な値 | デフォルト | 概要 |
1 | string? | No | html,htmlall,url,quotes,hex,hexentity,javascript | html | 使用するエスケープフォーマット |
htmlエスケープ・urlエスケープ・未エスケープの変数のシングルクォートのエスケープ・hexエスケープ・hexentityエスケープ・javascriptエスケープを行います。
デフォルトではhtmlエスケープが行われます。
デフォルトではhtmlエスケープが行われます。
例 5-10. escape
<?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"} {* & " ' < > をエスケープ *}
{$articleTitle|escape:"htmlall"} {* 全てのhtmlエンティティをエスケープ *}
{$articleTitle|escape:"url"}
{$articleTitle|escape:"quotes"}
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
出力 :
'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>