Open In App

PHP mb_encode_numericentity() Function

Last Updated : 28 Sep, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

The mb_encode_numericentity() function is an inbuilt function in PHP that is used to convert characters in a given string to their corresponding HTML numeric entity representations.

Syntax

mb_encode_numericentity(
    string $string,
    array $map,
    ?string $encoding = null,
    bool $hex = false
): string

Parameters

This function accepts four parameters that are described below.

  • $string: This parameter specifies the string that is to be decoded.
  • $map: The code area that is to be transformed, is represented by the map, which is an array.
  • hex: This parameter denotes either the entity reference will be hexadecimal notation or decimal notation.
  • $encoding: The encoding parameter denotes the character encoding. If omitted or null, then the internal character encoding value will be used.

Return Value

The mb_encode_numericentity() function returns the encoded string if the function successfully executes otherwise. It will return false.

Program 1: The following program demonstrates the mb_encode_numericentity() function.


Output
Bonjour tout le monde! Ça va bien ?

Program 2: The following program demonstrates the mb_encode_numericentity() function.

Output:

Hello, こんにちは!

Reference: https://www.php.net/manual/en/function.mb-encode-numericentity.php


Next Article

Similar Reads