php 无法调用内置的 mb_internal_encoding 方法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1216274/
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 01:34:51  来源:igfitidea点击:

Unable to call the built in mb_internal_encoding method?

phpmbstring

提问by Niels Basjes

I'm trying to install indefero on a CentOS 5.3 VMware 'box' and I ran into a problem. Quite early in the installation I get an error that I've been able to narrow down to this:

我正在尝试在 CentOS 5.3 VMware 'box' 上安装 indefero,但遇到了问题。在安装的早期,我收到一个错误,我已经能够缩小范围:

[root@code /var/www/html]# cat x.php
 <?php
     mb_internal_encoding("UTF-8");
 ?>
[root@code /var/www/html]# php x.php
PHP Fatal error:  Call to undefined function mb_internal_encoding() in 
/var/www/html/x.php on line 2

I get the same error when calling this script via http through Apache. Now according to the PHP manual the mb_internal_encoding functionshould be a builtin in PHP 5.

通过 Apache 通过 http 调用此脚本时出现相同的错误。现在根据PHP 手册,mb_internal_encoding 函数应该是 PHP 5 中的内置函数

I have CentOS 5.3 i386 (Linux code 2.6.18-53.1.21.el5 #1 SMP Tue May 20 09:34:18 EDT 2008 i686 i686 i386 GNU/Linux) and I've installed PHP 5.2.9.

我有 CentOS 5.3 i386(Linux 代码 2.6.18-53.1.21.el5 #1 SMP Tue May 20 09:34:18 EDT 2008 i686 i686 i386 GNU/Linux)并且我已经安装了 PHP 5.2.9。

[root@code /var/www/html]# php -v
PHP 5.2.9 (cli) (built: Jul  8 2009 06:03:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

I double checked: selinux has been disabled (for now).

我再次检查:selinux 已被禁用(目前)。

How do i fix this?

我该如何解决?

回答by Pascal MARTIN

mbstring is a "non-default" extension, that is not enabled by default ; see this pageof the manual :

mbstring 是一个“非默认”扩展,默认情况下不启用;请参阅手册的此页面

Installation

mbstring is a non-default extension. This means it is not enabled by default. You must explicitly enable the module with the configure option. See the Install section for details

安装

mbstring 是一个非默认扩展。这意味着它默认不启用。您必须使用配置选项显式启用模块。有关详细信息,请参阅安装部分

So, you might have to enable that extension, modifying the php.ini file (and restarting Apache, so your modification is taken into account)

因此,您可能必须启用该扩展,修改 php.ini 文件(并重新启动 Apache,以便将您的修改考虑在内)


I don't use CentOS, but you may have to install the extension first, using something like this (see this page, for instance, which seems to give a solution):


我不使用 CentOS,但您可能必须先安装扩展,使用类似的东西(例如,请参阅此页面,这似乎提供了解决方案)

yum install php-mbstring

(The package name might be a bit different ; so, use yum search to get it :-) )

(包名可能有点不同;所以,使用 yum search 来获取它:-))

回答by Akikon

For Debian/Ubuntu:

对于 Debian/Ubuntu:

sudo apt-get install php7.0-mbstring

sudo apt-get install php7.0-mbstring

回答by Balkrishna

If someone is having trouble with installing php-mbstringpackage in ubuntu do following sudo apt-get install libapache2-mod-php5

如果有人php-mbstring在 ubuntu 中安装软件包时遇到问题,请执行以下操作 sudo apt-get install libapache2-mod-php5

回答by Serhat Türkman

If you don't know how to enable php_mbstring extension in windows, open your php.ini and remove the semicolon before the extension:

如果您不知道如何在 Windows 中启用 php_mbstring 扩展,请打开您的 php.ini 并删除扩展前的分号:

change this

改变这个

;extension=php_mbstring.dll

to this

对此

extension=php_mbstring.dll

after modification, you need to reset your php server.

修改后,您需要重置您的php服务器。

回答by Mostafa

For OpenSUse (zypper package manager):

对于 OpenSUse(zypper 包管理器):

zypper install php5-mbstring

and:

和:

zyper install php7-mbstring

In the other hand, you can search them through YaST Software manager.

另一方面,您可以通过 YaST 软件管理器搜索它们。

Note that, you must restart apache http server:

请注意,您必须重新启动 apache http 服务器:

systemctl restart apache2.service