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
'预计对无棺材葬礼计划强烈反对'

继续学习
||
<?php echo "escape[编码]";
提交重置代码
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!