Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

mb_scrub

Description

Replace ill-formed byte sequences with the substitute character

Syntax

mb_scrub(
    string $string,
    ?string $encoding = null
): string

Parameters

string

The input string.

encoding

The encoding used to interpret string. If it is omitted or null, the mbstring.internal_encoding setting will be used if set, otherwise the default_charset setting will be used.

Return

The string result with invalid byte sequences replaced.

Examples

1 · string

<?

$string = '🐘string';

$return = mb_scrub($string);

echo $return;

?>
🐘string

2 · encoding

<?

$string = '🐘string';
$encoding = 'ASCII';

$return = mb_scrub($string, $encoding);

echo $return;

?>
????string
HomeMenu