htmlentities2

Convert entities, while preserving already-encoded entities.

Description

(string) htmlentities2( (string) $myHTML ); 

Returns (string)

Converted text.

Parameters (1)

0. $myhtml (string)
The text to be converted.

Usage

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

Defined (1)

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

/wp-includes/formatting.php  
  1. function htmlentities2( $myHTML ) { 
  2. $translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES ); 
  3. $translation_table[chr(38)] = '&'; 
  4. return preg_replace( "/&(?![A-Za-z]{0, 4}\w{2, 3};|#[0-9]{2, 3};)/", "&", strtr($myHTML, $translation_table) );