PHP mbstring doesn't work with Apache on Windo

2019-04-16 04:22发布

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(); ?> 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); ?> 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.

1条回答
闹够了就滚
2楼-- · 2019-04-16 04:43

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 example

I hope this will help you solve your problem.

查看更多
登录 后发表回答