Sunday, January 18, 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

Most Popular

Dominic
32474 POSTS0 COMMENTS
Milvus
118 POSTS0 COMMENTS
Nango Kala
6846 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12063 POSTS0 COMMENTS
Shaida Kate Naidoo
6985 POSTS0 COMMENTS
Ted Musemwa
7219 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6911 POSTS0 COMMENTS