2012-03-13 86 views
6

我得到這個錯誤:PHP缺少mb_strpos函數?

PHP Fatal error: Call to undefined function mb_strpos() in /my/file.php 

因爲mb_strpos()是PHP 4引進這是奇怪的,和我運行PHP 5.3.3

$ php -v 
PHP 5.3.3 (cli) (built: Feb 22 2012 19:38:14) 
Copyright (c) 1997-2010 The PHP Group 
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies 

任何人碰到這樣的事情,知道如何解決它?我搜查了,我無法弄清楚。

PS。我正在運行centOS 5.

+3

(也許它是沒有Unicode /多字節支持? – 2012-03-13 21:06:00

+1

您是否包含mbstring擴展名? ''phpinfo()''說什麼?查看http://ch2.php.net/mbstring瞭解更多信息。 – ckruse 2012-03-13 21:07:59

+0

你在名字空間嗎?您可能必須在函數前加上\。 – Rijk 2012-03-13 21:08:26

回答

13

MBSTRING是不是在PHP中的默認的擴展,你有,如果你運行的是Linux安裝它 嘗試

yum install php-mbstring.x86_64 # for RedHat derivative systems 

root用戶在Windows 或

apt-get install php-mbstring.x86_64 # for Debian derivative systems 

你必須編輯php.ini使用擴展dll庫

注意:mb_strpos仍然支持PHP 5

+1

-1,你假設每個人都使用相同的發行版,因爲它只是 – 2012-03-13 21:13:26

+0

這只是對解決方案的建議,我並不假定你所說的是什麼! – 2012-03-13 21:16:19

+0

你應該更具體一些關於「linux」 - 有十幾個linux發行版,並且只有少數在Ubuntu上使用'yum'作爲rpm-package-manager。例如,這將是'agt-get'。 |編輯:和一個不會「!!111oneeleven」,因爲它是粗魯和孩子氣。 – oezi 2012-03-13 21:18:00

1

我猜你的PHP版本不是用「--enable-mbstring」選項構建的。

您可以使用phpinfo()函數進行檢查。應該有一個「mbstring」部分。我有這個:

mbstring 

Multibyte Support enabled 
Multibyte string engine libmbfl 
HTTP input encoding translation disabled 
1

聽起來像它根本沒有安裝。請看看the documentation

mbstring is a non-default extension. This means it is not enabled by default. You must explicitly enable the module with the configure option. [...]

-1

這是一個基本的PHP功能。 看來你的虛擬主機沒有安裝MBSTRING PHP擴展。 檢查您的phpinfo();並在其中尋找mbstring。