解决:Call to undefined function mb_detect_encoding()

Linux:

首先使用yum或者apt安装mbstring.so,使用命令:yum install php-mbstring或者apt-get install php-mbstring (ubuntu用户最好使用apt-cache search mbstring搜索一番后再安装,软件名字可能有误)

然后修改php.ini:执行vim /etc/php.ini,加入extension="/usr/lib/php/modules/mbstring.so"内容,后面的路径可能不一样,根据mbstring.so存放的目录做相应的修改即可。一般是不用更改的。

Windows

1、找到php扩展目录(我的php扩展目录的路径是:C:\Program Files\AppServ\php\extensions)
     在extensions目录下面找到php_mbstring.dll文件,
2、将php_mbstring.dll这个文件拷贝到php.ini文件所在的目录下(我的php.ini文件所在的目录:C:\WINDOWS)
3、用记事本打开php.ini文件,使用快捷键Ctrl+F查找extension=php_mbstring.dll
4、 如果php.ini文件中存在extension=php_mbstring.dll,去掉该行extension前面的分号,
      如果不存在,就在其他extension=...的下一行加入extension=php_mbstring.dll,
      最终记得保存php.ini文件
5.   重新启动你的Apache服务器

【LAMP】Fatal error: Call to undefined function mb_detect_encoding()

06-15

我安装LAMP环境,php-xxx-.tar.gz解压缩后的目录 /home/default7/LAMP/php-5.5.13rnPHP安装到的目录 /usr/local/php5rn然后我安装之后,打开phpmyadmin,报错提示:rnrn[code=html]rnFatal error: Call to undefined function mb_detect_encoding() in /usr/local/apache2/htdocs/phpmyadmin/libraries/php-gettext/gettext.inc on line 177rn[/code]rnrn命令提示行查看php已经安装的模块:[b][color=#FF0000]mbstring是存在的[/color][/b]。rn[quote]rn[root@localhost php-5.5.13]# php -mrn[PHP Modules]rnbz2rncalendarrnCorernctyperncurlrndaterneregrnexifrnfileinfornfilterrnftprngettextrngmprnhashrniconvrnjsonrnlibxmlrnmbstringrnopensslrnpcntlrnpcrernPharrnreadlinernReflectionrnsessionrnshmoprnSimpleXMLrnsocketsrnSPLrnstandardrntokenizerrnxmlrnziprnzlibrnrn[Zend Modules]rnrn[/quote]rnrn[b]查看phpinfo,相关几个:[/b]rn[code=csharp]rnPHP Version 5.5.13rnConfigure Command rn './configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql' '--prefix=/usr/local/php5' rnrnServer APIrn Apache 2.0 HandlerrnrnVirtual Directory Supportrn enabledrnrnConfiguration File (php.ini) Pathrn /usr/local/php5/librnrnLoaded Configuration Filern /usr/local/php5/lib/php.inirnrnScan this dir for additional .ini files (none)rnAdditional .ini files parsed (none) rnextension_dirrn /usr/local/php5/lib/php/extensions/no-debug-zts-20121212rn /usr/local/php5/lib/php/extensions/no-debug-zts-20121212rnrn[/code]rnrn查看php5安装后的extension目录(是空的):rn[code=csharp]rn[root@localhost ext]# ll /usr/local/php5/lib/php/extensions/no-debug-zts-20121212rntotal 488rn-rwxr-xr-x. 1 root root 495775 Jun 15 01:01 opcache.sorn[root@localhost ext]# ll /usr/local/php5/lib/php/extensionsrntotal 4rndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 no-debug-zts-20121212rn[/code]rnrn但是在安装后的目录里面另外一个目录却有(目录 /usr/local/php5/include/php/ext):rn[code=c]rn[root@localhost ext]# pwdrn/usr/local/php5/include/php/extrn[root@localhost ext]# llrntotal 68rndrwxr-xr-x. 3 root root 4096 Jun 15 01:01 daterndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 domrndrwxr-xr-x. 3 root root 4096 Jun 15 01:01 eregrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 filterrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 hashrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 iconvrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 jsonrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 libxmlrndrwxr-xr-x. 2 root root 4096 Jun 15 01:02 mysqlndrndrwxr-xr-x. 3 root root 4096 Jun 15 01:01 pcrerndrwxr-xr-x. 2 root root 4096 Jun 15 01:02 pdorndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 pharrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 sessionrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 splrndrwxr-xr-x. 3 root root 4096 Jun 15 01:01 sqlite3rndrwxr-xr-x. 2 root root 4096 Jun 15 01:02 standardrndrwxr-xr-x. 2 root root 4096 Jun 15 01:02 xmlrn[root@localhost ext]# rnrn[/code]rnrnrn在安装文件夹(/home/default7/LAMP/php-5.5.13/ext)中有mbstring:rn[code=csharp]rn[root@localhost ext]# llrntotal 328rndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 bcmathrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 bz2rndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 calendarrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 com_dotnetrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:27 ctyperndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 curlrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:25 daterndrwxr-xr-x. 6 1001 1001 4096 May 28 17:06 dbarndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:27 domrndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 enchantrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:25 eregrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 exifrn-rwxr-xr-x. 1 1001 1001 8174 May 28 17:06 ext_skelrn-rw-r--r--. 1 1001 1001 1524 May 28 17:06 ext_skel_win32.phprndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:27 fileinforndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:28 filterrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 ftprndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 gdrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 gettextrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 gmprndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:43 hashrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:28 iconvrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 imaprndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 interbaserndrwxr-xr-x. 20 1001 1001 4096 May 28 17:06 intlrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:28 jsonrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 ldaprndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:26 libxmlrndrwxr-xr-x. 6 1001 1001 4096 May 28 17:06 mbstringrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 mcryptrndrwxr-xr-x. 2 1001 1001 4096 May 28 17:06 mssqlrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:28 mysqlrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 mysqlirndrwxr-xr-x. 3 1001 1001 4096 Jun 15 00:32 mysqlndrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 oci8rndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 odbcrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:35 opcacherndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 opensslrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pcntlrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:26 pcrerndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:28 pdorndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_dblibrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_firebirdrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_mysqlrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_ocirndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_odbcrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_pgsqlrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:29 pdo_sqliterndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pgsqlrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 01:41 pharrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:29 posixrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pspellrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 readlinerndrwxr-xr-x. 2 1001 1001 4096 May 28 17:06 recoderndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:29 reflectionrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:29 sessionrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 shmoprndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:29 simplexmlrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 skeletonrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 snmprndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 soaprndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 socketsrndrwxr-xr-x. 6 1001 1001 4096 Jun 15 00:29 splrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:26 sqlite3rndrwxr-xr-x. 5 1001 1001 12288 Jun 15 01:41 standardrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 sybase_ctrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 sysvmsgrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 sysvsemrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 sysvshmrndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 tidyrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:31 tokenizerrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 wddxrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:31 xmlrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:31 xmlreaderrndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 xmlrpcrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:31 xmlwriterrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 xslrndrwxr-xr-x. 5 1001 1001 4096 May 28 17:06 ziprndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 zlibrnrn[/code]rnrn在php.ini中有关extension_dir的都是注释掉了的,但是查看phpinfo却有mysql pdo 这些全都显示。rnrnrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭