Detailed analysis of WordPress filtering links and filtering SQL statements _php tips

Source: Internet
Author: User
Tags gopher nntp sql injection

Esc_url () (Filter link)
Many URLs will have small errors, with the Esc_url () function to mask or fix these errors, and to reject unsecured protocols.

What the Esc_url () function does:

Default reject is not the url:defaulting to HTTP, HTTPS, FTP, FTPS, mailto, news, IRC, gopher, NNTP, feed, and telnet of the following protocol
Delete invalid characters and dangerous characters
Convert characters to HTML entity characters
How to use

Esc_url ($url, $protocols, $_context);

Parameters

$url

(string) (must be) the URL to be filtered.

Default value: None

$protocols

(array) (optional) An array of protocols that can receive the protocol, if not set, the default is: Defaulting to HTTP, HTTPS, FTP, FTPS, mailto, news, IRC, gopher, NNTP, feeds, and Telnet.

Default value: None

$_context

(optionally) How to return the 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 at: wp-includes/formatting.php


Esc_sql () (Filter SQL statement)
Esc_sql () is used to filter the strings that are ready to be added to the SQL statement to prevent SQL injection and SQL statements from being disturbed by data interference.

Usage

Esc_sql ($data);

Parameters

$data

(string) (must) the string to be filtered.

Default value: None

return value

(string) returns the filtered string that can be added directly 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 at: wp-includes/formatting.php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.