In the context of Bitrix, the directive mbstring.func_overload is a setting often required by older versions of the Bitrix CMS (or self-hosted editions of Bitrix24). This setting ensures proper handling of multibyte strings, particularly for languages like Russian or other Cyrillic-based languages, which are common in Bitrix implementations.
How Bitrix Uses mbstring.func_overload
- Purpose:
- Bitrix may rely on multibyte-safe string functions (e.g., mb_strlen() instead of strlen()).
- The mbstring.func_overload directive ensures that PHP automatically substitutes standard functions (like strlen()) with multibyte-aware equivalents.
- Required Setting:
- Some versions of Bitrix require mbstring.func_overload = 2 in php.ini for proper functioning.
Setting mbstring.func_overload for Bitrix
Enable in php.ini
1
Open your PHP configuration file
sudo nano /etc/php/{version}/apache2/php.ini # For Apache
sudo nano /etc/php/{version}/cli/php.ini # For CLI
2
Look for the mbstring.func_overload directive or add it if missing
mbstring.func_overload = 2
3
Restart your web server
sudo systemctl restart apache2 # For Apache
sudo systemctl restart php-fpm # For Nginx
Bitrix-Specific Notes:
- Bitrix Admin Panel: You may see a warning in the admin panel if mbstring.func_overload is disabled or improperly set.
- If Bitrix does not explicitly require mbstring.func_overload, you can safely omit it, especially if using PHP 7.2+ (since it is deprecated).
What to Do in PHP 7.2+ or 8.0 (When mbstring.func_overload Is Removed)
1
Upgrade Bitrix
- Ensure you are using the latest version of Bitrix CMS or Bitrix24 that supports modern PHP versions.
- Older Bitrix versions may still rely on this deprecated directive.
2
Manually Use mb_* Functions
- Instead of relying on mbstring.func_overload, Bitrix developers should update their code to use mb_strlen(), mb_strpos(), and similar functions directly.
3
Disable the Directive
- Remove the mbstring.func_overload directive from php.ini and test Bitrix for compatibility with PHP 7.2+.
Check mbstring.func_overload Compatibility with Bitrix
1
Run the Bitrix Environment Check Script
- Bitrix provides a check script (bitrixsetup.php) to verify server compatibility.
- Upload the script to your server and run it via a browser:
- Look for any warnings about mbstring.func_overload.
http://yourdomain.com/bitrixsetup.php
2
Check PHP Logs
- Look for errors in PHP logs related to mbstring.func_overload:
tail -f /var/log/php_errors.log
Troubleshooting
| Issue | Solution |
|---|---|
| Bitrix warns about mbstring.func_overload | Enable it in php.ini or contact Bitrix support for an updated version. |
| PHP 7.2+ shows deprecation error | Remove the directive and ensure Bitrix code uses mb_* functions explicitly. |
| Multibyte string issues (Cyrillic) | Set mb_internal_encoding("UTF-8"); in your Bitrix configuration or in init.php. |
Example PHP Configuration for Bitrix
Here is a recommended snippet of php.ini for Bitrix with mbstring.func_overload:
[mbstring]
mbstring.language = Neutral
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.encoding_translation = Off
mbstring.func_overload = 2
mbstring.language = Neutral
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.encoding_translation = Off
mbstring.func_overload = 2


