Support Knowledge Base

How to enable mbstring in PHP?

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 ending 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.

MBstring Installation

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
 
#>php -m
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
 
#>yum install php-mbstring

This is true for all Red Hat Linux-based distributions using RPM and the ’yum’ package manager; this includes RHEL, Fedora, CentOS, Mandriva, and Intrinsic Linux, among others.
After that, you will need to restart your Apache service using the following command:
 
service httpd restart
Installation on Windows Server
 
If you have access to the php.ini, just remove the semicolon character (;) in front of the line below.
 
extension = php_mbstring.dll
Once you have made the changes, don't forget to restart your web server for the change to take effect.
 
Note : PHP 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.
 
mbstring Configuration
 
Below is a sample excerpt php.ini file which contains the configuration of mbstring variables.
[mbstring]
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
Custom Fields
  • Applicable To: Standard (Multi-Language) Edition, Enterprise Multi-Language Edition (MySQL), Enterprise Multi-Language Edition (SQL Server)
4.24 (33)
Article Rating (33 Votes)
Rate this article
Attached Files
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Name
Email
Security Code Security Code
Related Articles RSS Feed
Can I use the PHPKB software without active support subscription?
Viewed 9880 times since Mon, Aug 8, 2011
SEO Friendly URLs Not Working
Viewed 11465 times since Fri, Mar 18, 2016
Can I purchase more than 12 months of software maintenance?
Viewed 9797 times since Mon, Aug 8, 2011
Can I transfer my license to another domain?
Viewed 8997 times since Mon, Aug 29, 2011
How do I migrate/move my installation of PHPKB to another server?
Viewed 13250 times since Sat, May 12, 2012
How to enable text selection and copying on article page?
Viewed 9811 times since Thu, Jan 22, 2015
Support Subscription Renewal - Commonly Asked Questions
Viewed 7484 times since Wed, Jun 25, 2014