PHP 8.4.2 Released!

mb_scrub

(PHP 7 >= 7.2.0, PHP 8)

mb_scrubReplace ill-formed byte sequences with the substitute character

说明

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

Perform a character set conversion from the specified encoding, or the default encoding if no encoding was specified, to the same encoding. This has the effect of replacing any invalid byte sequences with the substitute character.

参数

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.

返回值

The string result with invalid byte sequences replaced.

更新日志

版本 说明
8.0.0 现在 encoding 可以为 null。
添加备注

用户贡献的备注 1 note

up
24
Sammitch
6 years ago
Replaces 'ill-formed' byte sequences with '?'.

See: https://github.com/php/php-src/pull/1099
To Top