14

I get this error:

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

Which is odd because mb_strpos() was introduced in PHP 4, and I'm running 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

Anybody else run into something like this and know how to fix it? I searched and I can't figure it out.

PS. I'm running centOS 5.

JKirchartz
  • 17,612
  • 7
  • 60
  • 88

6 Answers6

24

MBString is not a default extension in PHP and you have to install it if you are running linux try

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

as a root user or

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

on windows you have to edit php.ini to use the extension dll library

Note: mb_strpos still supported in PHP 5

JKirchartz
  • 17,612
  • 7
  • 60
  • 88
Muhannad A.Alhariri
  • 3,702
  • 4
  • 30
  • 46
  • 1
    -1 , you are assuming that everyone uses same distro as you do – tereško Mar 13 '12 at 21:13
  • you should be a bit more specific about "linux" - there are a dozen linux-distributions out there and only few are using `yum` as rpm-package-manager - on ubuntu. for example, this would be `agt-get`. | EDIT: and one shall not "!!!!111oneeleven" as it's rude and boyish. – oezi Mar 13 '12 at 21:18
  • 1
    ya you are right but the reader should distinguish and should be smart to adapt the solution to meet his needs – Muhannad A.Alhariri Mar 13 '12 at 21:19
  • 1
    the reader should be smart enought to look up the documentation, too. if you debate like this, stackoverflow is completely needless. – oezi Mar 13 '12 at 21:21
  • 8
    I had to install `php53-mbstring.x86_64`, but this was the most helpful answer. now quit fighting and take out your nerd-rage elsewhere. – JKirchartz Mar 13 '12 at 21:22
3

You need to find out which PHP your server is using by placing a info.php with this code:

<?php phpinfo(); ?>

Then you need to download php-mbstring for this version, e.g. if you have PHP 8.0.15 then you need to install it like this:

sudo apt-get install php8.0-mbstring

Then restart the apache2 service:

sudo service apache2 restart
Black
  • 18,150
  • 39
  • 158
  • 271
1

If you're using cPanel and have access to your WHM panel then you need to enable mbstring PHP Extension from your EasyApache 4.

Just go top WHM Home » EasyApache 4 » Customize

The search for mbstring under PHP Extensions and enable that as per your PHP versions (php80-php-mbstring).

For me it worked perfectly.

Dev Rathi
  • 703
  • 6
  • 8
1

I would guess that your version of PHP wasn't built with the "--enable-mbstring" option.

You can check with the phpinfo() function. There should be a "mbstring" section. Mine has this:

mbstring

Multibyte Support   enabled
Multibyte string engine libmbfl
HTTP input encoding translation disabled
jasonlfunk
  • 5,159
  • 4
  • 29
  • 39
1

sounds like it's simply not installed. please take a look at 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. [...]

oezi
  • 51,017
  • 10
  • 98
  • 115
-2

This is a basic PHP function. It seems your web host does not have the mbstring PHP extension installed. Check your phpinfo(); and look for mbstring in it.

Milap
  • 6,915
  • 8
  • 26
  • 46