class HtmlHelper

Class HtmlHelper

Methods

static string
encode(string $text, string $charset = 'utf-8')

Encodes special characters into HTML entities.

static string
decode(string $text)

This is the opposite of {@link encode()}.

static array
encodeArray(array $data, string $charset = 'utf-8')

No description

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

static array|string
unescap($data, int $type = 0, string $encoding = 'UTF-8')

去掉html转义

static string
stripImages(string $string)

Strip img-tags from string

static string
stripIframes(string $string)

Strip iframe-tags from string

static string
stripScript(string $string)

stripScript

static string
stripStyle(string $string)

stripStyle

static array
findImages(string $html, bool $onlySrc = true)

No description

static string
minify(string $html)

No description

Details

at line 24
static string encode(string $text, string $charset = 'utf-8')

Encodes special characters into HTML entities.

Parameters

string $text data to be encoded
string $charset

Return Value

string the encoded data

See also

http://www.php.net/manual/en/function.htmlspecialchars.php

at line 35
static string decode(string $text)

This is the opposite of {@link encode()}.

Parameters

string $text data to be decoded

Return Value

string the decoded data

See also

http://www.php.net/manual/en/function.htmlspecialchars-decode.php

at line 47
static array encodeArray(array $data, string $charset = 'utf-8')

Parameters

array $data data to be encoded
string $charset

Return Value

array the encoded data

See also

http://www.php.net/manual/en/function.htmlspecialchars.php

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

Parameters

$data
int $type
string $encoding

Return Value

array|mixed|string

at line 114
static array|string unescap($data, int $type = 0, string $encoding = 'UTF-8')

去掉html转义

Parameters

$data
int $type
string $encoding

Return Value

array|string

at line 137
static string stripImages(string $string)

Strip img-tags from string

Parameters

string $string Sting to be cleaned.

Return Value

string Cleaned string

at line 147
static string stripIframes(string $string)

Strip iframe-tags from string

Parameters

string $string Sting to be cleaned.

Return Value

string Cleaned string

at line 157
static string stripScript(string $string)

stripScript

Parameters

string $string

Return Value

string

at line 167
static string stripStyle(string $string)

stripStyle

Parameters

string $string

Return Value

string

at line 177
static array findImages(string $html, bool $onlySrc = true)

Parameters

string $html
bool $onlySrc

Return Value

array

at line 197
static string minify(string $html)

Parameters

string $html

Return Value

string