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
32662 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7037 POSTS0 COMMENTS
Nicole Veronica
12174 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12263 POSTS0 COMMENTS
Shaida Kate Naidoo
7161 POSTS0 COMMENTS
Ted Musemwa
7428 POSTS0 COMMENTS
Thapelo Manthata
7128 POSTS0 COMMENTS
Umr Jansen
7127 POSTS0 COMMENTS