# PHP – How to get the substitution character using mb_substitute_character()?

PHPServer Side ProgrammingProgramming

In PHP, we can use the function mb_substitute_character() to get the substitution character. This function specifies the substitution character when the input character encoding is not valid or the character code does not exist in the output character encoding.

Note: The invalid characters may be substituted with no output, string, or int value (Unicode character code value).

string mb_substitute_character($char) ## Parameters This function accepts only one parameter,$char.

• \$char− It specifies the Unicode value as an integer or the strings given below:

• "none"− It will return no output.

• "long"− It is used for the output character code value. For example, "U+3000, JIS+7E7E"

• "entity"− it is used to return the output character entity. For example, "&#x200".

## Return Values

If the mb_substitute_character is set, then it will return True for success or else it will return False. If it is not set, then it will return the current setting.

Note: PHP 8.0 does not support passing an empty string to substitute_character.

## Example

Live Demo

<?php
// It will set the Unicode U+3013
mb_substitute_character(0x3013);

?>
long