Use of PHP functions related to HTML and filtering links in WordPress. _ PHP Tutorial

Source: Internet
Author: User
Tags gopher nntp
WordPress uses HTML and PHP functions related to filtering links for parsing ,. The HTML function of WordPress is used for parsing and filtering links. the esc_html () (escape Html) esc_html () function is used to escape Html code, so that Html code is not escaped. Use es WordPress to parse HTML and PHP functions related to filtering links,

Esc_html () (escape Html)
The esc_html () function is used to escape Html code so that 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 escape character.

Example

echo esc_html( 'A link' );

The above code will be output:

WordPress function: esc_html () (escape Html)

(To prevent browser transcoding, I cut a picture directly)

More

This function is located in: wp-includes/formatting. php


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

Articles you may be interested in:
  • How to filter links and SQL statements in WordPress
  • Describes how to filter attributes and use SQL statements in WordPress development.

Escape, esc_html () (escape Html) the esc_html () function is used to escape Html code so that Html code is not escaped. Usage es...

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.