This WordPress function is usually used, especially when it is used to plug-ins or expand theme functions. I have written an article to note this and will use it later.
This esc_url function
Mainly used for URL filtering:
1. Deny URLs that are not the following protocols (defaulting to http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed, and telnet)
2. Remove invalid and dangerous characters.
3. Convert characters into HTML entities and convert & and single quotes (') into numeric entities: & #038, & #039.
Usage
$ Url
(String) (required) URL to be cleaned and filtered
Default: None
$ Protocols
(Array) (optional) can accept the protocol array. If not set, the default value is: 'http', 'http', 'ftp ', 'ftps', 'mailto ', 'news', 'irc', 'Gopher', 'nntp ', 'feed', and 'telnet '.
Default: None
$ _ Context
(String) (optional) how to return a URL.
Default: 'display'
The returned value is the filtered URL.
A simple example:
The code is as follows: |
Copy code |
<? Php Echo esc_url ('www .111cn.net '); // The output content is: http://www.111cn.net ?> |