Languages: English • 日本語 (Add your language)
Escaping for HTML blocks.
<?php esc_html( $text ) ?>
$html = esc_html( '<a href="http://www.example.com/">A link</a>' );
$html now contains this:
<a href="http://www.example.com/">A link</a>
Which would be displayed in an HTML document as:
<a href="http://www.example.com/">A link</a>
Instead of this:
echo esc_html( 'A & B' );
will print A & B
, instead of A &amp; B
esc_html() is located in wp-includes/formatting.php
.
See: Data Validation article for an in-depth discussion of input and output sanitization.