HtmlHelper
class HtmlHelper
Class HtmlHelper
Methods
Encodes special characters into HTML entities.
This is the opposite of {@link encode()}.
No description
html代码转义 htmlspecialchars 只转化这几个html [ & ' " < > ] 代码 --> [ & " ], 而 htmlentities 却会转化所有的html代码,连同里面的它无法识别的中文字符也会转化。 一般使用 htmlspecialchars 就足够了,要使用 htmlentities 时,要注意为第三个参数传递正确的编码。 htmlentities() <--> html_entity_decode() — 将特殊的 HTML 实体转换回普通字符 htmlspecialchars() <--> htmlspecialchars_decode() — 将特殊的 HTML 实体转换回普通字符 ENT_COMPAT ENT_QUOTES ENT_NOQUOTES ENT_HTML401 ENT_XML1 ENT_XHTML ENT_HTML5
去掉html转义
Strip img-tags from string
Strip iframe-tags from string
stripScript
stripStyle
No description
No description
Details
at line 24
static string
encode(string $text, string $charset = 'utf-8')
Encodes special characters into HTML entities.
at line 35
static string
decode(string $text)
This is the opposite of {@link encode()}.
at line 47
static array
encodeArray(array $data, string $charset = 'utf-8')
at line 82
static array|mixed|string
escape($data, int $type = 0, string $encoding = 'UTF-8')
html代码转义 htmlspecialchars 只转化这几个html [ & ' " < > ] 代码 --> [ & " ], 而 htmlentities 却会转化所有的html代码,连同里面的它无法识别的中文字符也会转化。 一般使用 htmlspecialchars 就足够了,要使用 htmlentities 时,要注意为第三个参数传递正确的编码。 htmlentities() <--> html_entity_decode() — 将特殊的 HTML 实体转换回普通字符 htmlspecialchars() <--> htmlspecialchars_decode() — 将特殊的 HTML 实体转换回普通字符 ENT_COMPAT ENT_QUOTES ENT_NOQUOTES ENT_HTML401 ENT_XML1 ENT_XHTML ENT_HTML5
at line 114
static array|string
unescap($data, int $type = 0, string $encoding = 'UTF-8')
去掉html转义
at line 137
static string
stripImages(string $string)
Strip img-tags from string
at line 147
static string
stripIframes(string $string)
Strip iframe-tags from string
at line 157
static string
stripScript(string $string)
stripScript
at line 167
static string
stripStyle(string $string)
stripStyle