跳至内容

unescape

unescape 用于解码 entityhtmlhtmlall。它会针对给定类型抵消 escape 修饰符 的作用。

基本用法

{$myVar|unescape}

参数

参数位置 类型 必需 可能值 默认值 描述
1 字符串 htmlhtmlallentity html 这是要使用的 escape 格式。
2 字符串 ISO-8859-1UTF-8,以及 htmlentities() 支持的任何字符集 UTF-8 传递至 html_entity_decode() 或 htmlspecialchars_decode() 或 mb_convert_encoding() 等的字符集编码。

范例

<?php

$smarty->assign('articleTitle',
                "Germans use &quot;&Uuml;mlauts&quot; and pay in &euro;uro"
                );

下面是示例 unescape 模板行,其后是输出

{$articleTitle}
Germans use &quot;&Uuml;mlauts&quot; and pay in &euro;uro

{$articleTitle|unescape:"html"}
Germans use "&Uuml;mlauts" and pay in &euro;uro

{$articleTitle|unescape:"htmlall"}
Germans use "Ümlauts" and pay in €uro

另请参阅 转义 smarty 解析escape 修饰符