PHP mbstring在Windows上不适用于Apache [英] PHP mbstring doesn't work with Apache on Windows

查看:106
本文介绍了PHP mbstring在Windows上不适用于Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须获得mbstring在Windows上与Apache 2.4(32位)一起运行的PHP 5.4(32位,TS).在我的httpd.conf文件中设置以下内容:

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

在我的php.ini中:

And in my php.ini:

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

现在,当我执行php -m时,它正确地表示已加载mbstring:

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

...
libxml
mbstring
mcrypt
...

然后php -i吐出有关mbstring的部分:

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
...

但是,当我有一个简单的带有<?php phpinfo(); ?>的index.php时,就没有关于mbstring的消息,即使它说使用了正确的php.ini.

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.

当我将index.php更改为<?php echo mb_convert_case("hello world", MB_CASE_UPPER); ?>时,发生错误

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

我可以使用PHP CLI php index.php运行完全相同的脚本,并且可以正确打印HELLO WORLD.

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

为什么mbstring在php.exe中起作用,而在Apache中却不起作用?当然,我无数次重启了Apache,甚至是整个PC.

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

推荐答案

我遇到了同样的问题,并使用cmd命令解决了该问题

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

  1. 关闭所有的Apache服务
  2. 以管理员身份运行cmd
  3. 在我的情况下,使用命令cd C:\Apache24\bin
  4. 转到apache的bin文件夹.
  5. 使用命令bin>mklink php.ini C:\php\php.ini
  6. 使用文件php.ini创建符号链接.
  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

示例:

我希望这可以帮助您解决问题.

I hope this will help you solve your problem.

这篇关于PHP mbstring在Windows上不适用于Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆