Skip to content

unescape

unescape 用于解码 entityhtmlhtmlall。它可以还原由给定类型的 escape 修饰符 所产生的效果。

基本用法

{$myVar|unescape}

参数

参数位置 类型 必需 可选值 默认值 描述
1 string htmlhtmlallentity html 要使用的解码格式。
2 string 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 修饰符