Mbstring php установка windows

Установка

mbstring не входит в список модулей, устанавливаемых
по умолчанию. Это значит, что изначально этот модуль отключён. Для
использования функций этого модуля необходимо явно включить его
с опцией configure. За дополнительной информацией
обращайтесь в раздел Инсталляция.

Следующие настройки относятся к модулю mbstring.

  • —enable-mbstring: Включение
    функций mbstring. Эта настройка необходима
    для использования функций mbstring.

    libmbfl необходима для работы
    mbstring. libmbfl
    поставляется вместе с mbstring. До PHP 7.3.0, если
    libmbfl уже установлена в системе,
    то можно использовать —with-libmbfl[=DIR]
    для использования установленной библиотеки.

  • —disable-mbregex: Отключение
    функций регулярных выражений, поддерживающих многобайтовые кодировки.

    Oniguruma необходима для
    функций, работающих с регулярными выражениями с поддержкой многобайтовых
    кодировок.
    Начиная с PHP 7.4.0, для обнаружения библиотеки libonig используется pkg-config.
    До PHP 7.4.0 Oniguruma поставлялась вместе с
    mbstring, но можно было выполнить сборку с уже установленным
    libonig, передав —with-onig[=DIR].

    Возможно запретить многобайтовые регулярные
    выражения с возвратом с помощью опции —disable-mbregex-backtrack.

Нашли ошибку?

Пользователи ещё не добавляли примечания для страницы


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, you may get an error that says:

Call to undefined function mb_convert_encoding()

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.

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

If you don’t have this installed on a Linux machine and if you have installed PHP from yum then run this command as a superuser. The command depends on your operating system.

sudo yum install php-mbstring
This command 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.
For Debian, Ubuntu distributions, please use the following command.

sudo apt-get install php-mbstring

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.

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 from 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

When running phpMyAdmin, you may see an error that says the mbstring extension is missing as follows:

This error prevents you from opening phpMyAdmin and accessing your database.

To solve this error, you need to have mbstring installed and activated in your PHP configuration.

Depending on your Operating System, there are different ways to install and enable the mbstring extension:

Install mbstring for Linux

For Linux systems, you can install mbstring using apt-get or yum depending on your Linux distribution.

Here’s the command to install mbstring for Debian / Ubuntu or Red Hat Linux:

sudo apt-get install php-mbstring

# for RHL:
sudo yum install php-mbstring

The package manager should install the right mbstring version based on your PHP version.

If not, you need to specify the version as follows:

# install mbstring v8.1
sudo apt-get install php8.1-mbstring

# install mbstring v7.4
sudo apt-get install php7.4-mbstring

Once the extenson is installed, you need to restart your PHP server.

For Apache, run the following command:

Now you can check if the mbstring extension is enabled by running phpinfo() function to see the mbstring enabled:

You can also run the php -m | grep mbstring command to see the extension from the command line:

$ php -m | grep mbstring
mbstring

Now that the mbstring extension is available, you should be able to access phpMyAdmin.

Install mbstring for Windows

For Windows system, you need to enable the mbstring extension from the php.ini file.

Look for the line extension=php_mbstring.dll in your php.ini file as follows:

;extension=php_mssql.dll
;extension=php_mbstring.dll
;extension=php_exif.dll  
extension=php_mysql.dll

You need to remove the semicolon before the extension config to enable php_mbstring.dll for Windows.

;extension=php_mssql.dll
extension=php_mbstring.dll
;extension=php_exif.dll  
extension=php_mysql.dll

Once you enable the extension, restart your PHP server. The mbstring extension should now be available on your Windows computer.

If that doesn’t work, search your php.ini file for the extension_dir config.

You should see where PHP look for the extensions as shown below:

extension_dir = "D:\XAMPP\php\ext"

You need to see if the php_mbstring.dll exists inside the D:\XAMPP\php\ext path. Copy the extension directory value and paste it to your explorer windows.

If the .dll file is not present, you need to download the PHP Windows build from windows.php.net as shown below:

Extract the downloaded zip file, then look for the php_mbstring.dll file from the ext/ folder. Copy the file to your extension_dir path.

I don’t recommend downloading dll files from the Internet because you may get a virus on your computer.

Restart your PHP server, and now the mbstring extension should be available.

And that’s how you enable mbstring on Windows computers.

Install mbstring for macOS

For macOS, the PHP formula from Homebrew already enabled the mbstring extension during the installation process.

You should have mbstring enabled by default when you install PHP using Homebrew.

But if you install PHP using MacPorts, then you may need to install mbstring separately.

The following command should work when you’re using MacPorts:

# 👇 install PHP 7.4 mbstring 

sudo port install php74-mbstring

# 👇 install PHP 8.0 mbstring 

sudo port install php80-mbstring

You can see the available mbstring version from macports.org.

Now you’ve learned how to enable the PHP mbstring extension on macOS. Good work! 👍

2018-07-31 09:29:14
Jon
36564
Last edited by Zeze on 2019-08-21 09:28:59
  • About mbstring
  • FAQ
  • Install mbstring
  • Linux
  • 1. CenOS
  • 2. Ubuntu
  • Windows

About mbstring

Each language has its own encoding and the number of bytes is different. mbstring extension is to ensure that different coded languages in PHP program can be displayed properly.

FAQ

1. When executing phpMyAdmin, an error message shows,
«The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.» Or

2. When using the application,
an error message shows,

«Uncaught Error: Call to undefined function mb_strlen();»

Both are due to your PHP did not install mbstring.

Install mbstring

Linux


1. CenOS


php installation package path: /data/php5.6.14/
PHP installation path: /usr/local/php/

(Set the path according to your actual situation. Below is an example)


Find the directory of mbstring in PHP installation package.

cd /data/php5.6.14/ext/mbstring/

Execute phpize

/usr/local/php/bin/phpize

Compile and install

./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

Now mbstring.so is generated in  /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/

Add the code below to php.ini

extension=mbstring.so

Restart PHP and check whether PHP-curl is installed using phpinfo()

2. Ubuntu

sudo apt-get install php5.6-mbstring

Add

extension=php5.6-mbstring.so to the configuration file.

Restart Ubuntu and it should work.

Windows


Alter php.ini

Remove «;» from

;
extension=php_mbstring.dll

. If there is no such code, add
extension=php_mbstring.dll

If not working after restarting your web server, copy
php_mbstring.dll  in your PHP folder to C:\WINDOWS\system32.

Restart it and it should work.

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Windows 10 pro consumer edition что это
  • Как открыть включение или отключение компонентов windows 10
  • Чистка системного реестра windows 10
  • Что делать если диск с переполнен а удалять нечего windows 10
  • Свойство экрана windows 10