PHP Call to undefined function mb_strlen() 启用 php_mbstring

Php 2020-07-01 阅读 22 评论 0

问题描述

在 PHP 代码中,使用 mb_strlen 方法,报错了。

Call to undefined function mb_strlen()

解决方法

需要启用 mbstring。

Linux/Unix

可以重新编译 PHP 或者单独编译 mbstring

1. 重新编译 PHP

编译 PHP 时,加上 --enable-mbstring

$ ./configure --prefix=/opt/php --enable-mbstring
$ make
$ sudo make install

2. 单独编译 mbstring

进入 PHP 的源代码。

$ cd ext/mbstring
$ ./configure --prefix=/opt/php-5.4.45 --with-php-config=/opt/php-5.4.45/bin/php-config
$ make
$ sudo make install

编辑 php.ini,添加 mbstring.so 扩展。

extension = mbstring.so

Windows

在 php.ini 中,去掉 ;extension=php_mbstring.dll 前面的 ; 符号。

extension=php_mbstring.dll
最后更新 2020-07-01
MIP.watch('startSearch', function (newVal, oldVal) { if(newVal) { var keyword = MIP.getData('keyword'); console.log(keyword); // 替换当前历史记录,新增 MIP.viewer.open('/s/' + keyword, {replace: true}); setTimeout(function () { MIP.setData({startSearch: false}) }, 1000); } }); MIP.watch('goHome', function (newVal, oldVal) { MIP.viewer.open('/', {replace: false}); });