htmlentities2() WordPress Function

The htmlentities2() function is a built-in function in WordPress that is used to convert all applicable characters to HTML entities. This function is similar to the htmlentities() function, with the only difference being that htmlentities2() also converts UTF-8 characters to HTML entities.

htmlentities2( string $myHTML ) #

Converts entities, while preserving already-encoded entities.


Parameters

$myHTML

(string)(Required)The text to be converted.


Top ↑

Return

(string) Converted text.


Top ↑

Source

File: wp-includes/formatting.php

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

Top ↑

Changelog

Changelog
VersionDescription
1.2.2Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More