Thursday, July 30, 2026
HomeLanguagesPHP mb_substitute_character() Function

PHP mb_substitute_character() Function

The mb_substitute_character() is an inbuilt function in PHP that sets or retrieves the substitution character used when a multi-byte string cannot be represented in the specified character encoding.

Syntax:

mb_substitute_character($substitute_character ): string|int|bool

Parameters: This function accepts only one parameter which is described below.

  • $substitute_character: This parameter is used to specify the Unicode value in the form of an integer, long, character entity, or none in the case when there is no output.

Return Value: If the substitution character is set, it will return “true” otherwise it will return “false”.  If the substitution character is not, it will return the default setting.

Example 1: The following program demonstrates the mb_substitute_character() function.

PHP




<?php
$subchar = mb_substitute_character();
echo "Current substitution character: $subchar";
?>


Output:

Current substitution character: 63

Example 2: The following program demonstrates the mb_substitute_character() function.

PHP




<?php
echo "The subtitution character = ".mb_substitute_character('long');
?>


Output:

The subtitution character = 1  

Reference: https://www.php.net/manual/en/function.mb-substitute-character.php

RELATED ARTICLES

3 COMMENTS

Most Popular

Dominic
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6903 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6981 POSTS0 COMMENTS
Umr Jansen
6973 POSTS0 COMMENTS