![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP – How to get the substitution character using mb_substitute_character()?
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).
Syntax
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, "Ȁ".
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
<?php // It will set the Unicode U+3013 mb_substitute_character(0x3013); // Hexadecimal format mb_substitute_character("long"); // It will display current setting echo mb_substitute_character(); ?>
Output
long