Signatur
mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool
Beschreibung
Nützlich, um ungültige UTF-8-Sequenzen aus User-Input zu erkennen.
Parameter
| Name | Typ | Default | Beschreibung |
|---|---|---|---|
| $value | string|null | null | Eingabe. |
| $encoding | ?string | null | Encoding. |
Rückgabewert
Typ
bool
Beispiele
UTF-8 validieren
<?php
if (!mb_check_encoding($input, 'UTF-8')) {
throw new InvalidArgumentException('Ungültiges UTF-8');
}