PHP mbstring 不适用于 Windows 上的 Apache

标签 php windows apache php-extension mbstring

我必须获得 PHP 5.4(32 位,TS)以及在 Windows 上与 Apache 2.4(32 位)一起运行的 mbstring。在我的 httpd.conf 中我设置了这个:

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

在我的 php.ini 中:

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

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

...
libxml
mbstring
mcrypt
...

php -i吐出一段关于 mbstring 的内容:

mbstring

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

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

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

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 .

为什么 mbstring 在 php.exe 中可以工作,但在 Apache 中却不行?当然,我多次重新启动 Apache,甚至重新启动整个电脑。

最佳答案

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

  1. 关闭所有 apache 服务
  2. 以管理员身份运行cmd
  3. 转到 apache 的 bin 文件夹,在我的例子中,使用命令 cd C:\Apache24\bin
  4. 使用命令 bin>mklink php.ini C:\php\php.ini 创建与文件 php.ini 的符号链接(symbolic link)

示例:

cmd example

希望这能帮助您解决问题。

关于PHP mbstring 不适用于 Windows 上的 Apache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34263544/

相关文章:

php - SQL 查询在 PHP PDO 上重复并且与 phpmyadmin 上的结果不同

php - Exception([string $exception [, long $code ]]) 参数错误

php - 如何拒绝登录用户访问路由?

windows - 启动应用程序时 jvm.dll 丢失错误

javascript - 更改图像的特定区域并在该区域填充颜色

python - 简单的 Python 脚本无法正确执行

json - 终端外壳程序路径 "..\..\..\vsCode\git\bin\bash.exe"在VS Code Windows中不存在

apache2 web 服务器 index.html 问题

apache - ProducerTemplate 和 Direct :start in camel

php - Ubuntu PHP APACHE2 全新安装问题