The mbstring.func_overload directive ensures that Bitrix CMS (or Bitrix24) handles multibyte strings correctly, particularly for non-ASCII characters such as Cyrillic. This directive replaces standard PHP string functions like strlen(), substr(), and strpos() with their multibyte-safe equivalents (mb_strlen(), mb_substr(), mb_strpos()).
However, since mbstring.func_overload has been deprecated in PHP 7.2 and removed in PHP 8.0, you need to handle it carefully, depending on your PHP version and Bitrix configuration.
Steps to Set mbstring.func_overload for Bitrix
Enable mbstring.func_overload in php.ini
Locate the php.ini File
The php.ini file is typically located in:
- /etc/php/{version}/apache2/php.ini for Apache.
- /etc/php/{version}/cli/php.ini for command-line PHP.
- /etc/php/{version}/fpm/php.ini for Nginx with PHP-FPM.
Edit the File
Open the file using a text editor:
Find or Add mbstring.func_overload
Add or modify the directive:
Restart the Web Server
For Apache:
For Nginx (PHP-FPM):
Verify the Setting
To ensure mbstring.func_overload is enabled:
- Using phpinfo():
- Create a PHP file (e.g., info.php) with the following content:
- Open it in a browser (http://yourdomain.com/info.php) and search for mbstring.func_overload.
- Using Command Line: Run the following command:
phpinfo();
?>
Output should show:
Adjust Bitrix Environment
If mbstring.func_overload is required by your version of Bitrix:
- Ensure that all other mbstring settings in php.ini are correctly configured:
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
Handling mbstring.func_overload in PHP 7.2+
Check PHP Version
- If you are using PHP 7.2 or later, the mbstring.func_overload directive is deprecated.
- If you are using PHP 8.0 or later, it is removed and should not be used.
Remove the Directive
If your PHP version does not support mbstring.func_overload, remove it from php.ini:
Comment out or delete the line:
Update Bitrix Code
- Replace calls to standard string functions (strlen(), substr()) with multibyte-safe functions (mb_strlen(), mb_substr()) directly in the codebase if necessary.
- Alternatively, contact Bitrix Support for a version of Bitrix compatible with modern PHP versions.
Testing for Bitrix Compatibility
- Run Bitrix Environment Check Script: Download and run the Bitrix environment check script to verify all server settings:
- Fix Any Detected Warnings: The script will flag any misconfigurations, including issues related to mbstring.func_overload.
Best Practices for Modern PHP Versions
If mbstring.func_overload is unavailable or not recommended for your PHP version:
- Set Internal Encoding Manually: Add this to your Bitrix init.php file:
- Use mb_* Functions in Custom Scripts: Replace any standard string functions with multibyte-safe versions:
- strlen() > mb_strlen()
- strpos() > mb_strpos()
- substr() > mb_substr()
- Upgrade to a Bitrix Version Compatible with PHP 7.2+ or 8.0: Older versions of Bitrix may rely on deprecated functionality. Upgrading ensures compatibility with modern environments.
Troubleshooting Common Issues
| Problem | Solution |
|---|---|
| Bitrix requires mbstring.func_overload | Enable it in php.ini if using PHP < 7.2. |
| Error: "mbstring.func_overload is removed in PHP 8" | Remove the directive and update Bitrix or use mb_* functions. |
| Cyrillic characters not displayed correctly | Ensure mb_internal_encoding("UTF-8") is set and files are saved in UTF-8 encoding. |
| PHP logs show errors after removal | Debug Bitrix codebase for unsupported functions like strlen() and replace with mb_strlen(). |
- If you are using PHP 7.1 or earlier, enable mbstring.func_overload = 2 for Bitrix to ensure proper multibyte string handling.
- For PHP 7.2+, avoid using mbstring.func_overload and update your Bitrix installation or use mb_* functions in your scripts.
- Always test your server environment with the Bitrix environment check script.


