PHP字符串函数htmlspecialchars()的用法

技术教程2个月前发布 北陌
407 00

PHP字符串函数htmlspecialchars()的用法

htmlspecialchars

(PHP 4, PHP 5)

htmlspecialchars — Convert special characters to HTML entities

说明

string htmlspecialchars
( string $string
[, int $flags = ENT_COMPAT | ENT_HTML401
[, string $encoding = ini_get(“default_charset”)
[, bool $double_encode = true
]]] )

Certain characters have special significance in HTML, and should
be represented by HTML entities if they are to preserve their
meanings. This function returns a string with these
conversions made. If you require all input substrings that have associated
named entities to be translated, use htmlentities()
instead.

If the input string passed to this function and the final document share the
same character set, this function is sufficient to prepare input for
inclusion in most contexts of an HTML document. If, however, the input can
represent characters that are not coded in the final document character set
and you wish to retain those characters (as numeric or named entities),
both this function and htmlentities() (which only encodes
substrings that have named entity equivalents) may be insufficient.
You may have to use mb_encode_numericentity() instead.

The translations performed are:

© 版权声明

相关文章

暂无评论

none
暂无评论...