unescape
unescape 用于解码 entity、html 和 htmlall。它可以还原由给定类型的 escape 修饰符 所产生的效果。
基本用法
{$myVar|unescape}
参数
| 参数位置 | 类型 | 必需 | 可选值 | 默认值 | 描述 |
|---|---|---|---|---|---|
| 1 | string | 否 | html、htmlall、entity |
html |
要使用的解码格式。 |
| 2 | string | 否 | ISO-8859-1、UTF-8,以及由 htmlentities() 支持的任何字符集编码 |
UTF-8 |
传递给 html_entity_decode()、htmlspecialchars_decode() 或 mb_convert_encoding() 等的字符集编码。 |
示例
<?php
$smarty->assign('articleTitle',
"Germans use "Ümlauts" and pay in €uro"
);
以下是示例 unescape 模板行及其输出:
{$articleTitle}
Germans use "Ümlauts" and pay in €uro
{$articleTitle|unescape:"html"}
Germans use "Ümlauts" and pay in €uro
{$articleTitle|unescape:"htmlall"}
Germans use "Ümlauts" and pay in €uro
另请参阅转义 Smarty 解析、escape 修饰符。