Describes how to filter links and SQL statements in WordPress ,. The method for filtering links and SQL statements in WordPress is described in detail. many URLs of esc_url () (filtering links) may have small errors. you can use the esc_url () function to block or correct these errors, describes how to filter links and SQL statements in WordPress,
Esc_url () (filter link)
Many URLs have small errors. Using the esc_url () function can block or correct these errors and reject insecure protocols.
Work content of the esc_url () function:
The default DENY is not the URL of the following protocol: defaulting to http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed, and telnet.
Delete invalid and dangerous characters
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 that can receive protocols. If no protocol is set, the default value is: defaulting to http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed, and telnet.
Default value: None
$ _ Context
(String) (optional) how to return a URL.
Default value: (string) display
Return value
(String) returns the filtered link.
Example
<? Php echo esc_url ('www .endskin.com '); // output: http://www.endskin.com?>
More
This function is located in: wp-includes/formatting. php
Esc_ SQL () (filter SQL statements)
Esc_ SQL () is used to filter the strings to be added to SQL statements to prevent SQL injection and exceptions caused by data interference.
Usage
esc_sql( $data );
Parameters
$ Data
(String) (required) the string to be filtered.
Default value: None
Return value
(String) the filtered string can be directly added to the SQL statement.
Example
$name = esc_sql( $name );$status = esc_sql( $status );$wpdb->get_var( "SELECT something FROM table WHERE foo = '$name' and status = '$status'" );
More
This function is located in: wp-includes/formatting. php
Articles you may be interested in:
- Use of PHP functions related to HTML and filtering links in WordPress
- Describes how to filter attributes and use SQL statements in WordPress development.
Large, esc_url () (filtering links) many URLs may have some minor errors. you can use the esc_url () function to block or correct these errors ,...