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 escape.
Default value: None
Return value
(String) Returns the escaped characters.
Example
echo esc_html( '<a href="http://www.example.com/">A link</a>' );
The above code will output:
WordPress function: esc_html() (escape Html)
(To prevent the browser from transcoding, I directly screenshot a picture)
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:
Reject URLs that are not the following protocols by default: defaulting to http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed and telnet
Remove invalid characters and dangerous ones Character
Convert characters into HTML entity characters
Usage
esc_url( $url, $protocols, $_context );
Parameters
$url
(string) (required) The 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: None
$_context
(String) (optional) How to return the URL.
Default value: (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
The above introduces the analysis of the use of PHP functions related to escaping HTML and filtering links in WordPress, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.