简体   繁体   中英

PHPSpreadsheet undefined function mb_strlen

I got phpspreadsheet installed but am getting an error:

PHP Fatal error: Call to undefined function PhpOffice\\PhpSpreadsheet\\Shared\\mb_strlen() in /opt/apache/htdocs/mysite/tools/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php on line 469

Here is the code used to call phpspreadsheet:

require '../vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

From what I found it means the plugin mbstring isnt working/installed but my PHP says it is installed:

# php -m
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
gd
hash
iconv
intl
json
libxml
mbstring
mhash
mysql
mysqli
openssl
pcre
PDO
pdo_mysql
Phar
Reflection
session
SimpleXML
SPL
sqlite3
standard
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

Any idea if something else is missing or how I can fix this?

CLI configuration is separate from web configuration. Depending on your environment you have to change the php.ini file that is being used when PHP is accessed via whatever web server you use.

In order to check what is the location of the php.ini file in use, you can run phpinfo() from your web app (not CLI). The phpinfo() output will have information of php.ini file location.

So everything points to it being installed and working, but it was still giving the error. I even verified the mbstring.so actually exists where it should be and is in the php.ini and not commented.

I tried to install it but got 'nothing to do' since its already there.

What I did to fix this is uninstall mbstring then install it again from opencsw (where I install all my php packages from).

After doing that and restarting apache again, it is no longer giving me the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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