PHP use Mbstring (multi-byte string) extension to convert strings to a different encoding. It is used to express more than 256 characters in a regular byte. Sometimes you will get a Mbstring extension missing error. In this tutorial, we will check how to fix this issue.
CONTENTS
How do I fix mbstring extension is missing?
We can fix it in different ways. So let’s check which method will solve your mbstring extension missing problem.
Also Read: Check if a string contains a specific word in PHP?
Method 1 – Changing PHP version:
- First upgrade or downgrade your PHP version.
- Restart apache server.
Method 2 – Installing mbstring extension on Linux:
If you are using Linux and PHP version 7.3 or any, follow the below steps-
- Open the terminal.
- Run sudo apt-get install php7.3-mbstring
- Restart the Apache server sudo service apache2 restart
Method 3 – Installing mbstring extension on Windows:
If you are a Windows user and using WAMP OR XAMPP, you have to find PHP installation location. As I am using WAMP, so the location is “C:\wamp64\bin\php\php7.3.5”. Here php7.3.5 is my current version. For XAMPP go to its installation location and find the PHP folder.
Also Read: How to target a specific city to show your website in PHP?
But if you are not using WAMP or XAMPP then go to “C:\php”. After that follow the below steps-
- After got to PHP directory, find php.ini and open it.
- Search for “extension_dir” and check if it is uncommented i.e. no semicolon(;) in front of “extension_dir“. If it is present, remove the semicolon.
- Then set the “ext” directory location as its value. Check the image below.
- As I am using PHP 7.3 so the “ext” directory location is “C:\wamp64\bin\php\php7.3.5\ext”
- Change extension_dir = “ext” into extension_dir = “C:\wamp64\bin\php\php7.3.5\ext” (write your own path depending on your PHP location)
- Now search for this ;extension=mbstring and remove ; from that line i.e extension=mbstring
- Save your php.ini and restart.