php 致命错误:调用未定义的函数 mb_detect_encoding()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17204437/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:29:03  来源:igfitidea点击:

Fatal error: Call to undefined function mb_detect_encoding()

phpmbstring

提问by Louis93

I receive this error after trying to set up LAMP by following this tutorial, and I find myself receiving the above error after trying to set up phpmyadmin.

我尝试按照本教程设置 LAMP 后收到此错误,并且在尝试设置 phpmyadmin 后发现自己收到上述错误。

Fatal error: Call to undefined function mb_detect_encoding() in C:\WebServer\Apache\htdocs\phpmyadmin\libraries\php-gettext\gettext.inc on line 177

致命错误:在第 177 行调用 C:\WebServer\Apache\htdocs\phpmyadmin\libraries\php-gettext\gettext.inc 中未定义的函数 mb_detect_encoding()

I followed the advice over here: PHP Fatal error when trying to access phpmyadmin mb_detect_encoding, and made those changes.

我遵循了这里的建议:尝试访问 phpmyadmin mb_detect_encoding 时出现 PHP Fatal error,并进行了这些更改。

When I run phpinfo(), I see that support for MySQL and mb_stringare enabled as shown below:

当我运行时phpinfo(),我看到对 MySQL 的支持并mb_string启用如下所示:

mb_string

mb_string

MySQL

MySQL

mysqli

mysqli

采纳答案by Jibu K

Install the gd library also.

也安装 gd 库。

check this link http://www.php.net/manual/en/mbstring.installation.php

检查此链接 http://www.php.net/manual/en/mbstring.installation.php

回答by Phil LaNasa

There's a much easier way than recompiling PHP. Just yum install the required mbstring library:

有一种比重新编译 PHP 更简单的方法。只需 yum 安装所需的 mbstring 库:

Example: How to install PHP mbstring on CentOS 6.2

示例:如何在 CentOS 6.2 上安装 PHP mbstring

yum --enablerepo=remi install php-mbstring

Oh, and don't forget to restart apache afterward.

哦,别忘了之后重新启动 apache。

回答by BSB

Mbstring is a non-default extension. This means it is not enabled by default. You must explicitly enable the module with the configure option.

Mbstring 是一个非默认扩展。这意味着它默认不启用。您必须使用配置选项显式启用模块。

In case your php version is 7.0:

如果您的 php 版本是 7.0:

sudo apt-get install php7.0-mbstring

sudo service apache2 restart

In case your php version is 5.6:

如果您的 php 版本是 5.6:

sudo apt-get install php5.6-mbstring

sudo service apache2 restart

回答by André Ribeiro

On Windows open the file php.ini and make this changes:

在 Windows 上打开文件 php.ini 并进行以下更改:

Remove the comment and point to the ext directory

去掉注释,指向ext目录

; extension_dir = "./" -> extension_dir = "C:/Php/ext"

; extension_dir = "./" -> extension_dir = "C:/Php/ext"

Remove the comment of this extensions

删除此扩展的注释

  • extension=php_mbstring.dll
  • extension=php_mysqli.dll
  • 扩展名=php_mbstring.dll
  • 扩展名=php_mysqli.dll

Restart apache service

重启apache服务

httpd -k restart

httpd -k 重启

回答by abhishek shringi

When I opened my php.ini file, "extension_dir" line looked like following :

当我打开 php.ini 文件时,“extension_dir”行如下所示:

extension_dir = "C:/wamp/bin/php/php5.4.16/ext/"

which i changed to:

我改为:

extension_dir = "C:\wamp\bin\php\php5.4.16\ext\"

and it worked.

它奏效了。

回答by rightstuff

Under Windows / WAMP there doesn't seem to be any php_mbstring.dll dependencies on the GD2 extension, the MySQL extensions, nor on external dlls/libs:

在 Windows / WAMP 下,GD2 扩展、MySQL 扩展或外部 dll/lib 似乎没有任何 php_mbstring.dll 依赖项:

deplister.exe ext\php_mbstring.dll

deplister.exe ext\php_mbstring.dll

php5ts.dll,OK
MSVCR110.dll,OK
KERNEL32.dll,OK

deplister.exe ext\php_gd2.dll

deplister.exe ext\php_gd2.dll

php5ts.dll,OK
USER32.dll,OK
GDI32.dll,OK
KERNEL32.dll,OK
MSVCR110.dll,OK

Whatever php_mbstring already needs, it's built-in (statically compiled right into the DLL).

无论 php_mbstring 已经需要什么,它都是内置的(静态编译到 DLL 中)。

Call to undefined function mb_detect_encoding()

调用未定义的函数 mb_detect_encoding()

This error is also very specific and deterministic...

这个错误也是非常具体和确定的......

The function mb_detect_encoding()didn't fail because php_gd, php_mysql, php_mysqli, or another extension was not loaded; it simply was NOT found.

该函数mb_detect_encoding()不会因为 php_gd、php_mysql、php_mysqli 或其他扩展程序未加载而失败;它只是没有找到。

I'm guessing that all the answers that are reported as valid (for Windows / WAMP), that say to load other extensions, to change php.ini extension_dirpaths (if this one was wrong to begin with, NO extensions would load), etc, work more due to a) un-commenting the extension = php_mbstring.dllline, or b) restarting Apache or the computer (for changes to take effect).

我猜所有被报告为有效的答案(对于 Windows / WAMP),比如加载其他扩展,更改 php.iniextension_dir路径(如果这个路径一开始是错误的,则不会加载任何扩展)等,由于 a) 取消注释该extension = php_mbstring.dll行,或 b) 重新启动 Apache 或计算机(以使更改生效),因此工作更多。

On Windows, most of the time the problem is that php_mbstring.dll is either:

在 Windows 上,大多数时候问题是 php_mbstring.dll 是:

  • Blocked by Windows. Unblock it by right-clicking it, check Properties.

  • Or PHP can't load php_mbstring.dll due to another version getting loaded (e.g., from some improper PHP DLLs install into C:\Windows\system32), some version mismatch, missing run-time DLLs, etc. Check Apache's and PHP's error log files first for clues.

  • 被 Windows 阻止。通过右键单击它来取消阻止它,检查属性。

  • 或者 PHP 无法加载 php_mbstring.dll 由于另一个版本被加载(例如,从一些不正确的 PHP DLL 安装到 C:\Windows\system32)、某些版本不匹配、缺少运行时 DLL 等。检查 Apache 和 PHP 的错误首先记录文件以获取线索。

More in-depth answer here: Call to undefined function mb_detect_encoding

更深入的答案在这里:调用未定义的函数 mb_detect_encoding

回答by user3413723

For fedora/centos/redhat:

对于 Fedora/centos/redhat:

yum install php-mbstring

yum install php-mbstring

Then restart apache

然后重启apache

回答by ironarm

The problem could also be that Apache can't find php.ini If you set PHPIniDir incorrectly. Mine was set to: PHPIniDir "c:/php7" But, the folder is actually just "php" The clue was viewing phpinfo() Which showed: Configuration File (php.ini) Path C:\windows

问题也可能是 Apache 找不到 php.ini 如果您错误地设置了 PHPIniDir。我的设置为: PHPIniDir "c:/php7" 但是,该文件夹实际上只是 "php" 线索是查看 phpinfo() 其中显示:配置文件 (php.ini) 路径 C:\windows

回答by user2615161

you should use only english version of phpmyadmin if you are using all languages you should enable all languages mbstring in php.in file.....just search for mbstring in php.in

如果您使用所有语言,您应该只使用英文版本的 phpmyadmin,您应该在 php.in 文件中启用所有语言 mbstring.....只需在 php.in 中搜索 mbstring

回答by daniele cocilova

I had the same problem with Ubuntu 17, Ispconfigwas not processing the operations queued of any kind and also the server.shcommand was not working. I checked and the running PHP version after the OS upgrade was 7.1 so the solution was to type:

我在 Ubuntu 17 上遇到了同样的问题,Ispconfig没有处理任何类型的排队操作,而且server.sh命令也不起作用。我检查了操作系统升级后正在运行的 PHP 版本是 7.1,因此解决方案是键入:

apt-get install php7.1-mbstring

and now is everything ok

现在一切正常