Friday, November 14, 2025
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
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7142 POSTS0 COMMENTS
Thapelo Manthata
6837 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS