WordPress 函数:esc_html()(转义 Html)

esc_html() 函数用来转义 Html 代码,让 Html 代码不转义。

用法

esc_html( $text );

参数

$text

(字符串)(必须)要转义的字符串。

默认值:None

返回值

(字符串)返回转义后的字符。

例子

echo esc_html( '<a href="http://www.example.com/">A link</a>' );

上边的代码将输出:

&lt;a href="http://www.example.com/"&gt;A link&lt;/a&gt;

更多

此函数位于:wp-includes/formatting.php

更多过滤函数https://pdbn.top/tags/wordpress-filter-function