mb_regex_encoding()
mb_regex_encoding() — Set/Get character encoding for multibyte regex.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
mb_regex_encoding(?string $encoding = null): string|bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $encoding | ?string | The encoding parameter is the character encoding. If it is omitted or null, the internal character encoding value will be used. |
Return value
If encoding is set, then Returns true on success or false on failure. In this case, the internal character encoding is NOT changed. If encoding is omitted, then the current character encoding name for a multibyte regex is returned.
Example
The PHP manual ships no example for mb_regex_encoding(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 8.0.0 | encoding is nullable now. |
| 8.0.0 | Now throws a ValueError if encoding is an invalid encoding. Previously, an E_WARNING was emitted and false was returned. |
See also
mb_internal_encoding(), mb_ereg()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page mb_regex_encoding() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.