简体   繁体   中英

PHP mbstring doesn't work with Apache on Windows

I have to get PHP 5.4 (32 bit, TS) with mbstring running with Apache 2.4 (32 bit) on Windows. In my httpd.conf I set this:

PHPIniDir "c:/php54"
LoadModule php5_module "c:/php54/php5apache2_4.dll"
AddHandler application/x-httpd-php .php

And in my php.ini:

extension_dir = "ext"
...
extension=php_mbstring.dll

Now, when I execute php -m it correctly says that mbstring is loaded:

...
libxml
mbstring
mcrypt
...

And php -i spits out a section about mbstring:

mbstring

Multibyte Support => enabled
Multibyte string engine => libmbfl
HTTP input encoding translation => disabled
libmbfl version => 1.3.2
...

But, when I have a simple index.php with <?php phpinfo(); ?> <?php phpinfo(); ?> there is no word about mbstring, even though it says the correct php.ini was used.

When I change index.php to <?php echo mb_convert_case("hello world", MB_CASE_UPPER); ?> <?php echo mb_convert_case("hello world", MB_CASE_UPPER); ?> it errors with

Fatal error: Call to undefined function mb_convert_case() in C:\Apache24x86\htdocs\index.php on line 1

I can run the exact same script with PHP CLI php index.php and it correctly prints HELLO WORLD .

Why is mbstring working in php.exe, but not in Apache? Of course I restarted Apache numerous times and even my whole PC.

I had the same problem and I solved it with a cmd command

  1. Turn off all the apache services
  2. Run cmd as administrator
  3. Go to the bin folder of apache, in my case, with the command cd C:\\Apache24\\bin
  4. create a symbolic link with the file php.ini with the command bin>mklink php.ini C:\\php\\php.ini

Example:

cmd示例

I hope this will help you solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM