gpt4 book ai didi

PHP mbstring 不适用于 Windows 上的 Apache

转载 作者:可可西里 更新时间:2023-11-01 11:49:18 26 4
gpt4 key购买 nike

我必须获得 PHP 5.4(32 位,TS),mbstring 在 Windows 上与 Apache 2.4(32 位)一起运行。在我的 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 时没有关于 mbstring 的消息,尽管它说使用了正确的 php.ini。

当我将 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 无数次,甚至重启了我的整个 PC。

最佳答案

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

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

例子:

cmd example

希望本文能帮助您解决问题。

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com