esc_html() (escape Html)
The esc_html() function is used to escape Html code so that the Html code is not escaped.
Usage
esc_html( $text );
Parameters
$text
(String) (Required) The string to be escaped.
Default value: None
Return value
(String) Returns the escaped character.
Example
echo esc_html( '<a href="http://www.example.com/">A link</a>' );
The above code will output:
WordPress function: esc_html() (escape Html)
(In order to prevent the browser from transcoding, I directly took a screenshot)
More
This function is located at: wp-includes/formatting.php
esc_url() (filter link)
Many URLs will have some minor errors. Use the esc_url() function to block or correct these errors, and reject unsafe protocols.
What the esc_url() function does:
Defaulting to URLs that are not the following protocols: defaulting to http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed and telnet
Remove invalid and dangerous characters
Convert characters to HTML entity characters
How to use
esc_url( $url, $protocols, $_context );
Parameters
$url
(String) (required) URL to be filtered.
Default value: None
$protocols
(array) (optional) An array of protocols that can be received. If not set, the default is: defaulting to http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed and telnet.
Default value: None
$_context
(String) (optional) How to return the URL.
Default: (String) display
Return value
(String) Returns the filtered link.
Example
<?php echo esc_url( 'www.endskin.com' );//输出:http://www.endskin.com ?>
More
This function is located at: wp-includes/formatting.php