mb_encode_numericentity
Encode characters into HTML numeric string references
Function name: mb_encode_numericalentity()
Applicable version: PHP 4 >= 4.0.6, PHP 5, PHP 7
Function description: Encode non-ASCII characters in a string into character entities in decimal or hexadecimal
usage:
string mb_encode_numericentity ( string $str , array $convmap , string $encoding = mb_internal_encoding() , bool $is_hex = false ): string
parameter:
Return value: encoded string.
Example:
$str = "Hello, 世界!"; $convmap = array(0x80, 0x10FFFF, 0, 0xFFFD); $encoded_str = mb_encode_numericentity($str, $convmap, 'UTF-8', true); echo $encoded_str;
Output:
Hello, 世界!
In the above example, we encode the non-ASCII characters in the string "Hello, World!" as a hexadecimal character entity. The hexadecimal code of the character "world" is 4E16, and the hexadecimal code of the character "world" is 754C, so the output result is "Hello, world!".