简体   繁体   English

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

[英]PHP: Call to undefined function mb_strlen() - on custom compiled PHP with mbstring enabled

I have this custom compiled PHP (v5.3.3) with the following extensions enabled (via configure): 我有这个自定义编译的PHP(v5.3.3),启用了以下扩展(通过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: phpinfo()明确指出mbstring已启用: 替代文字

Funny thing is when I try to run some PHP scripts (SugarCRM updates), it reports the following error: 有趣的是,当我尝试运行一些PHP脚本(SugarCRM更新)时,它会报告以下错误:

PHP Fatal error: Call to undefined function mb_strlen() in crm/include/pclzip/pclzip.lib.php on line 4165 PHP致命错误:在第4165行的crm / include / pclzip / pclzip.lib.php中调用未定义的函数mb_strlen()

Can anyone throw some light into WHY this is happening and how to fix this? 任何人都可以为这是为什么会发生这种情况以及如何解决这个问题?

Thanks, m^e 谢谢,m ^ e

On my Windows system with PHP and Apache, I had to modify the PHP.INI file so that it includes the following line: 在我使用PHP和Apache的Windows系统上,我不得不修改PHP.INI文件,使其包含以下行:

extension=php_mbstring.dll

(inside the main [PHP] section) and restart Apache. (在主[PHP]部分内)并重启Apache。 After that, the call to mb_strlen did succeed. 之后,对mb_strlen的调用确实成功了。

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 ; 对于PHP 4.3.3或更高版本,要启用该功能,您必须向LANG参数--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). --enable-mbstring = cn用于简体中文支持, - enable-mbstring = tw用于繁体中文支持, - enable-mbstring = kr用于韩语支持, - enable-mbstring = ru用于俄语支持,以及--enable -mbstring = ja表示日语支持(默认)。 To enable all supported encoding, use --enable-mbstring=all 要启用所有支持的编码,请使用--enable-mbstring = all

try 尝试

  • configure again with --enable-mbstring only 再次使用--enable-mbstring配置

  • grep mb_strlen $PATH_TO_YOUR_PHP_BINARY to see is it exist grep mb_strlen $PATH_TO_YOUR_PHP_BINARY看它是否存在

Simple solution. 简单解决方案

Instead mb_strlen() only use strlen() . 相反, mb_strlen()只使用strlen()

To me, it worked a few times. 对我来说,它工作了几次。

I had the same problem, this is an issue with php version. 我遇到了同样的问题,这是php版本的一个问题。

first run 首轮

sudo apt install php-mbstring

to install mbstring to the latest installed version of php 将mbstring安装到最新安装的php版本

then run: 然后运行:

 sudo apt-get dist-upgrade

and restart apache with 并重启apache

 sudo /etc/init.d/apache2 restart

Good luck 祝好运

Put this phpinfo() in a some php file for the output. 把这个phpinfo()放在一个php文件中输出。 And look for MbString seperate box there, if it is not present, then it is not installed properly. 并在那里寻找MbString单独的盒子,如果它不存在,那么它没有正确安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM