常用函数-wp_specialchars()

0条评论

常用函数-wp_specialchars()

说明

将若干特定字符转换成HTML实体字符。

这与 htmlspecialchars有所不同,因为已有HTML实体字符不会被编码。特别注意要将 &转换为 &#038;, < 转换为&lt; 以及 > 转换为 &gt;。

对' to &#039;进行编码时,可以将$quotes设为'single';对" to &quot; 进行编码时则设为'double';对两者同时编码时,则设为'1'。默认值为0,不对引号进行编码。

用法

<?php wp_specialchars( $text, $quotes ) ?>

参数

$text

(字符串)(必需)被编码的文本

默认值:None

$quotes

(混合)(可选)若参数设为'single',将所有单个引号进行转换;若参数设为'double',将所有双引号进行转换,设为其他值时则转换所有引号。

默认值:0

返回的值

(字符串)

被编码的HTML实体符号文章。

示例

注释

修改记录

自1.2.2版本后

源文件

wp_specialchars()位于 wp-includes/formatting.php中。

相关资源

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.