Codex tools: Log in
Languages: English • Português do Brasil • 中文(简体) • (Add your language)
Contents |
Encodes < > & " ' (less than, greater than, ampersand, double quote, single quote). Will never double encode entities.
Always use when escaping user-input, in forms especially.
对于字符串进行转义字符处理。
<?php echo esc_attr( $text ) ?>
<?php
echo '<input type=\"text\" id=\"user-email\" name=\"user-email\" value=\"' . esc_attr( $_POST['email'] ) . '\">';
?>
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.