Sunday, September 22, 2024
Google search engine
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

Recent Comments