- php-mbstring 설치
- Fatal error: Call to undefined function mb strlen()
문제 상황
Fatal error: Call to undefined function mb_strlen()
Fatal error: Call to undefined function mb_convert_encoding()
[root@localhost ~]# php -r 'mb_strlen();'
PHP Fatal error: Call to undefined function mb_strlen() in Command line code on line 1
- → mb_strlen 함수를 알아보지 못한다. php-mbstring이 설치되지 않았나 보다.
확인
[root@zetawiki ~]# rpm -qa php-mbstring
- → 설치되지 않음
[root@zetawiki ~]# yum info php-mbstring | grep Repo
Repo : Daum
- → yum으로 설치가능 (저장소는 Daum.repo 참고)
설치
[root@zetawiki ~]# yum install php-mbstring -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-mbstring.x86_64 0:5.3.3-3.el6_2.8 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================
Package Arch Version Repository Size
==================================================================================================================
Installing:
php-mbstring x86_64 5.3.3-3.el6_2.8 Daum 453 k
Transaction Summary
==================================================================================================================
Install 1 Package(s)
Total download size: 453 k
Installed size: 2.1 M
Downloading Packages:
php-mbstring-5.3.3-3.el6_2.8.x86_64.rpm | 453 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php-mbstring-5.3.3-3.el6_2.8.x86_64 1/1
Verifying : php-mbstring-5.3.3-3.el6_2.8.x86_64 1/1
Installed:
php-mbstring.x86_64 0:5.3.3-3.el6_2.8
Complete!
재확인
[root@zetawiki ~]# rpm -qa php-mbstring
php-mbstring-5.3.3-3.el6_2.8.x86_64
- → 패키지 설치됨
[root@zetawiki ~]# php -r 'mb_strlen();'
PHP Warning: mb_strlen() expects at least 1 parameter, 0 given in Command line code on line 1
Warning: mb_strlen() expects at least 1 parameter, 0 given in Command line code on line 1
- → mb_strlen 함수의 인수 개수가 잘못되었다고 함. 이제 PHP에서 mb_strlen 함수를 사용할 수 있다.
웹에서도 함수를 사용가능하게 하려면 httpd를 재시작해야 한다.
[root@zetawiki ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]