1

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.

felixfbecker
  • 2,273
  • 1
  • 19
  • 24
  • 2
    maybe this answer can help you: http://stackoverflow.com/a/25432880/5297359 – swidmann Dec 14 '15 at 09:36
  • The Web SAPI and the CLI SAPI typically have different php.ini files, you need to make sure that you've changed the appropriate one.... if you're running `php -m` from the command line, and see that it's installed, then you've probably only enabled it for the CLI SAPI – Mark Baker Dec 14 '15 at 09:40
  • Maybe you have a different config file being loaded for CLI as you do for the web server. Also you have to restart the web server for a number of config changes to take effect. Look at the ini-file portion of phpinfo from both the commandline and the phpinfo page you set up – GordonM Dec 14 '15 at 09:45
  • Also, I think support for PHP 5.4 ended with the release of PHP 7. You might want to look into upgrading to at least 5.6 – GordonM Dec 14 '15 at 09:46
  • @MarkBaker I can see in phpinfo() that it is the correct ini file and I also set PHPIniDir. – felixfbecker Dec 14 '15 at 09:48
  • @swidmannn this was the right tip. Thank you. If you want to post this as answer I can accept it. – felixfbecker Dec 14 '15 at 09:48
  • @GordonM I restarted and everything. It's the correct ini. I know it is old and unsupported, but my client is still running it, so I have to get my development environment setup before I can test if it breaks with PHP7. – felixfbecker Dec 14 '15 at 09:50
  • 1
    Possible duplicate of [mbstring missing from phpinfo but enabled in php.ini](http://stackoverflow.com/questions/25414785/mbstring-missing-from-phpinfo-but-enabled-in-php-ini) – swidmann Dec 14 '15 at 10:03

1 Answers1

2

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.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Gianfranco
  • 21
  • 2
  • I had the same issue. My php dir is on D:. So I opened a cmd as administrator and went to C:\ and typed `mklink /D php D:\php.inì` and that resolved my issues – Tschallacka Jan 29 '18 at 20:30