Codex tools: Log in
Languages: English • Português do Brasil • 中文(简体) • (Add your language)
Contents |
Encodes the <, >, &, " and ' (less than, greater than, ampersand, double quote and single quote) characters. Will never double encode entities.
Always use when escaping HTML attributes (especially form values) such as alt, value, title, etc. To escape and echo the value of a translation use esc_attr_e() instead.
<?php $fname = esc_attr( $fname ); ?>
<?php echo '<input type="text" name="fname" value="' . esc_attr( $_POST['fname'] ) . '">'; ?>
Since: 2.8.0
esc_attr() is located in wp-includes/formatting.php.
See: Data Validation article for an in-depth discussion of input and output sanitization.