How to enable mbstring in PHP?Estimated Reading Time: 3 Minutes
It is required to have PHP enabled with mbstring (multi-byte string) support for storing and displaying multi-byte characters in PHPKB software. The installation wizard of the multi-language editions of PHPKB knowledge base software will automatically detect if you have PHP enabled with mbstring support. If it is not enabled, please refer to the tutorial below on how to enable mbstring on your server.
Why mbstring is required?
When we manipulate (trim, split, splice, etc.) strings encoded in a multi-byte encoding, we need to use special functions since two or more consecutive bytes may represent a single character in such encoding schemes. Otherwise, if we apply a non-multibyte-aware string function to the string, it probably fails to detect the beginning or end of the multibyte character and ends up with a corrupted garbage string that most likely loses its original meaning.
So, mbstring provides multibyte specific string functions that help us deal with multibyte encodings in PHP. In addition to that, mbstring handles character encoding conversion between the possible encoding pairs. mbstring is designed to handle Unicode-based encodings such as UTF-8 and UCS-2 and many single-byte encodings for convenience.
Please note that "mbstring" is a non-default PHP extension. This means it is not enabled by default.
Installation on Linux Server
You can find out if this module is installed or not by looking at the list that is produced by this command
If you don’t have this installed on Linux machine and if you have installed php from yum then run this command as super user
After that, you will need to restart your Apache service using the following command:
Installation on Windows Server
If you have access to the php.ini, just remove the semicolon character (;) in front of the line below.
Once you have made the changes, don't forget to restart your web server for the change to take effect.
NNote:HP extensions are not just enabled from php.ini file. First, you need to install that specific extension, i.e. place its DLL file "php-mbstring.dll" into the "/php/ext/" directory if it is not already present there. When you do that, make sure you have the correct build of DLL file. 32-bit, thread-safe PHP binary, built using VC9 for example, would only work with DLL files built using exact same tools and configuration: 32-bit, using VC9, with thread-safety turned on. And of course PHP API version also needs to match. If it doesn't, once you restart the web server, you will receive 'Error 500 - Server error' message.
Below is a sample excerpt php.ini file which contains the configuration of mbstring variables.
mbstring.language = all
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.encoding_translation = On
mbstring.detect_order = UTF-8
mbstring.substitute_character = none;
mbstring.func_overload = 0
mbstring.strict_encoding = Off
- Applicable To: Standard (Multi-Language) Edition, Enterprise Multi-Language Edition (MySQL), Enterprise Multi-Language Edition (SQL Server)