WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/esc html

Description

Escaping for HTML blocks.

Usage

<?php esc_html$text ?>

Parameters

$text
(string) (required) Text to escape
Default: None

Return Values

HTML (string) 
Escaped HTML string.

Examples

$html = esc_html( '<a href="http://www.example.com/">A link</a>' );

$html now contains this:

&lt;a href=&quot;http://www.example.com/&quot;&gt;A link&lt;/a&gt;

Which would be displayed in an HTML document as:

<a href="http://www.example.com/">A link</a>

Instead of this:

A link

Notes

  • Uses the 'esc_html' filter.

Change Log

Source File

esc_html() is located in wp-includes/formatting.php.

Related

See: Data Validation article for an in-depth discussion of input and output sanitization.

See also index of Function Reference and index of Template Tags.