escape[编码]
escape[编码]
test.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', "'对无棺葬礼计划抱有强烈反对'");
$smarty->display('test.html');
test.html:
{$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>
输出:
'预计将强烈反对无棺材葬礼计划”
'预计将强烈反对无棺材葬礼计划”
“预计将强烈反对无棺材葬礼计划”
“预计将强烈反对无棺材葬礼计划” #039;
%27强烈+反对+预期+对+无棺材+葬礼+计划%27
'预计对无棺材葬礼计划强烈反对'