[CENTOS] [PHP] Solved "mb_strpos cannot be used"

background

After installing php, an error occurred in the mb_strpos function, so I will write it as a memorandum.

environment

CentOS Linux release 8.2.2004 (Core) PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )

Error information

After using the mb_strpos function in the console, an error occurs if it is not defined

php > echo mb_strpos("ontama", "a");
php > mb_strpos PHP Warning:  Uncaught Error: Call to undefined function mb_strpos() in php shell code:1 Stack trace:

Cause

In the case of Centos, it seems that mb_strpos is not available by default, so it seems that you need to install the package Install php-mbstring required when using multibyte string related functions

[root@localhost etc]# yum install -y php-mbstring

Reboot the OS

[root@localhost etc]# reboot

Start the console and check if the mb_strpos function can be used

[root@localhost etc]# php -a
php > echo mb_strpos("ontama", "a");
3

Confirm that it can be used safely.

reference

The one that I forgot to put in when building the php environment and moss ... https://qiita.com/sango/items/a86f9b8cf8c9c641823a

Recommended Posts

[PHP] Solved "mb_strpos cannot be used"
Because getSupportLoaderManager cannot be used
[Rails 6] method :: delete cannot be used with link_to
Why Java String typeclass comparison (==) cannot be used
Please note that Spring Boot + Tomcat 8.5.8 cannot be used!
Systemctl cannot be used on Ubuntu inside Docker container
Java Stream cannot be reused.
Note that system properties including JAXBContext cannot be used in Java11