PHP:调用未定义函数 mb_strlen() - 在启用 mbstring 的自定义编译 PHP 上

发布于 2024-10-03 06:49:56 字数 1551 浏览 9 评论 0原文

我有这个自定义编译的 PHP (v5.3.3),并启用了以下扩展(通过配置):

./configure 
--prefix=/usr/local/php5.3.3 
--with-config-file-path=/usr/local/apache2/conf 
--with-apxs2=/usr/local/apache2/bin/apxs 
--with-bz2 
--with-curl=/usr/lib 
--with-curlwrappers 
--with-freetype-dir=/usr/local 
--with-gd=/usr/local 
--with-gettext 
--with-gmp 
--with-iconv=/usr/local 
--with-imap=/usr/local/imap2007e 
--with-imap-ssl 
--with-jpeg-dir=/usr/local/lib 
--with-kerberos 
--with-libxml-dir=/usr/lib 
--with-mcrypt=/usr/local 
--with-mhash 
--with-mysql=/usr/lib/mysql 
--with-mysql-sock=/var/lib/mysql/mysql.sock 
--with-mysqli=/usr/lib/mysql/mysql_config 
--with-openssl=/usr 
--with-pcre-dir=/usr/local/lib 
--with-pear 
--with-png-dir=/usr/local/lib 
--with-readline 
--with-sqlite 
--with-xmlrpc 
--with-xsl=/usr/local 
--with-zlib-dir=/usr/local/lib 
--with-zlib=/usr/local 
--without-pgsql 
--enable-bcmath 
--enable-calendar 
--enable-exif 
--enable-embedded-mysqli=shared 
--enable-ftp 
--enable-gd-jis-conv 
--enable-gd-native-ttf 
--enable-mbstring=all 
--enable-mbregex 
--enable-shared 
--enable-sockets 
--enable-soap 
--enable-sqlite-utf8 
--enable-zend-multibyte 
--enable-zip 
--disable-pdo 
--disable-phar 

phpinfo() 清楚地表明 mbstring 已启用: alt text

有趣的是,当我尝试运行一些 PHP 脚本(SugarCRM 更新)时,它报告以下错误:

PHP 致命错误:在 crm/include/pclzip/pclzip.lib.php 第 4165 行调用未定义函数 mb_strlen()

任何人都可以解释为什么会发生这种情况以及如何解决此问题吗?

谢谢, 米^e

I have this custom compiled PHP (v5.3.3) with the following extensions enabled (via configure):

./configure 
--prefix=/usr/local/php5.3.3 
--with-config-file-path=/usr/local/apache2/conf 
--with-apxs2=/usr/local/apache2/bin/apxs 
--with-bz2 
--with-curl=/usr/lib 
--with-curlwrappers 
--with-freetype-dir=/usr/local 
--with-gd=/usr/local 
--with-gettext 
--with-gmp 
--with-iconv=/usr/local 
--with-imap=/usr/local/imap2007e 
--with-imap-ssl 
--with-jpeg-dir=/usr/local/lib 
--with-kerberos 
--with-libxml-dir=/usr/lib 
--with-mcrypt=/usr/local 
--with-mhash 
--with-mysql=/usr/lib/mysql 
--with-mysql-sock=/var/lib/mysql/mysql.sock 
--with-mysqli=/usr/lib/mysql/mysql_config 
--with-openssl=/usr 
--with-pcre-dir=/usr/local/lib 
--with-pear 
--with-png-dir=/usr/local/lib 
--with-readline 
--with-sqlite 
--with-xmlrpc 
--with-xsl=/usr/local 
--with-zlib-dir=/usr/local/lib 
--with-zlib=/usr/local 
--without-pgsql 
--enable-bcmath 
--enable-calendar 
--enable-exif 
--enable-embedded-mysqli=shared 
--enable-ftp 
--enable-gd-jis-conv 
--enable-gd-native-ttf 
--enable-mbstring=all 
--enable-mbregex 
--enable-shared 
--enable-sockets 
--enable-soap 
--enable-sqlite-utf8 
--enable-zend-multibyte 
--enable-zip 
--disable-pdo 
--disable-phar 

phpinfo() clearly states that mbstring is enabled:
alt text

Funny thing is when I try to run some PHP scripts (SugarCRM updates), it reports the following error:

PHP Fatal error: Call to undefined function mb_strlen() in crm/include/pclzip/pclzip.lib.php on line 4165

Can anyone throw some light into WHY this is happening and how to fix this?

Thanks,
m^e

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

紫罗兰の梦幻 2024-10-10 06:49:56

对于 PHP 4.3.3 或之前版本,要启用该功能,您必须向 --enable-mbstring=LANG 的 LANG 参数提供以下选项之一; --enable-mbstring=cn 表示简体中文支持,--enable-mbstring=tw 表示繁体中文支持,--enable-mbstring=kr 表示韩语支持,--enable-mbstring=ru 表示俄语支持,--enable -mbstring=ja 用于日语支持(默认)。要启用所有支持的编码,请使用 --enable-mbstring=all

尝试

  • 仅使用 --enable-mbstring 再次配置

  • grep mb_strlen $PATH_TO_YOUR_PHP_BINARY 查看它是否存在

For PHP 4.3.3 or before, To enable that feature, you will have to supply either one of the following options to the LANG parameter of --enable-mbstring=LANG ; --enable-mbstring=cn for Simplified Chinese support, --enable-mbstring=tw for Traditional Chinese support, --enable-mbstring=kr for Korean support, --enable-mbstring=ru for Russian support, and --enable-mbstring=ja for Japanese support (default). To enable all supported encoding, use --enable-mbstring=all

try

  • configure again with --enable-mbstring only

  • grep mb_strlen $PATH_TO_YOUR_PHP_BINARY to see is it exist

凑诗 2024-10-10 06:49:56

在装有 PHP 和 Apache 的 Windows 系统上,我必须修改 PHP.INI 文件,使其包含以下行:(

extension=php_mbstring.dll

在主 [PHP] 部分内)并重新启动 Apache。之后,对 mb_strlen 的调用确实成功了。

On my Windows system with PHP and Apache, I had to modify the PHP.INI file so that it includes the following line:

extension=php_mbstring.dll

(inside the main [PHP] section) and restart Apache. After that, the call to mb_strlen did succeed.

梦过后 2024-10-10 06:49:56

我也遇到了同样的问题,这是php版本的问题。

首先运行

sudo apt install php-mbstring

将 mbstring 安装到最新安装的 php 版本,

然后运行:

 sudo apt-get dist-upgrade

并重新启动 apache 祝

 sudo /etc/init.d/apache2 restart

你好运

I had the same problem, this is an issue with php version.

first run

sudo apt install php-mbstring

to install mbstring to the latest installed version of php

then run:

 sudo apt-get dist-upgrade

and restart apache with

 sudo /etc/init.d/apache2 restart

Good luck

辞别 2024-10-10 06:49:56

将此 phpinfo() 放入某个 php 文件中以进行输出。并查找那里的 MbString 单独框,如果它不存在,则说明安装不正确。

Put this phpinfo() in a some php file for the output. And look for MbString seperate box there, if it is not present, then it is not installed properly.

追我者格杀勿论 2024-10-10 06:49:56

简单的解决方案。

相反,mb_strlen() 仅使用 strlen()

对我来说,它有效了几次。

Simple solution.

Instead mb_strlen() only use strlen().

To me, it worked a few times.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文