esc_html

Escaping for HTML blocks.

Description

(string) esc_html( (string) $text ); 

Returns (string)

Parameters (1)

0. $text (string)
The text.

Usage

  1. if ( !function_exists( 'esc_html' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // The text. 
  5. $text = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = esc_html($text); 
  9.  

Defined (2)

The function is defined in the following location(s).

/wp-includes/formatting.php  
  1. function esc_html( $text ) { 
  2. $safe_text = wp_check_invalid_utf8( $text ); 
  3. $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); 
  4. /** 
  5. * Filters a string cleaned and escaped for output in HTML. 
  6. * Text passed to esc_html() is stripped of invalid or special characters 
  7. * before output. 
  8. * @since 2.8.0 
  9. * @param string $safe_text The text after it has been escaped. 
  10. * @param string $text The text prior to being escaped. 
  11. */ 
  12. return apply_filters( 'esc_html', $safe_text, $text ); 
/wp-includes/l10n.php  
  1. function esc_html__( $text, $domain = 'default' ) { 
  2. return esc_html( translate( $text, $domain ) );