Florian Peschka Florian Peschka - 2 months ago 22
PHP Question

mbstring missing from phpinfo but enabled in php.ini

Similar to this question: gd2 not showing in phpinfo, is showing in php -i

I have the same problem with

mbstring
. I enabled it in my
php.ini
(which is the only
php.ini
on my whole system - and yes, I checked and double checked that!
), but when I open up
phpinfo
on my Apache, mbstring is missing. If I do
php -i
, all of the
mbstring
data is showing up nicely.

Apache (
phpinfo.php
)

Configuration File (php.ini) Path C:\Windows
Loaded Configuration File F:\PHP\5.4\php.ini
Scan this dir for additional .ini files (none)
Additional .ini files parsed (none)


Apache (
index.php
)

Fatal error: Call to undefined function mb_get_info()
in F:\Apache\httpd-2.4\htdocs\index.php on line 2


PHP CLI:

F:\Apache\httpd-2.4\htdocs> php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: F:\PHP\5.4\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)

F:\Apache\httpd-2.4\htdocs> php index.php
array(14) {
["internal_encoding"]=>
string(10) "ISO-8859-1"
["http_output"]=>
string(4) "pass"
["http_output_conv_mimetypes"]=>
string(31) "^(text/|application/xhtml\+xml)"
["func_overload"]=>
int(0)
["func_overload_list"]=>
string(11) "no overload"
["mail_charset"]=>
string(5) "UTF-8"
["mail_header_encoding"]=>
string(6) "BASE64"
["mail_body_encoding"]=>
string(6) "BASE64"
["illegal_chars"]=>
int(0)
["encoding_translation"]=>
string(3) "Off"
["language"]=>
string(7) "neutral"
["detect_order"]=>
array(2) {
[0]=>
string(5) "ASCII"
[1]=>
string(5) "UTF-8"
}
["substitute_character"]=>
int(63)
["strict_detection"]=>
string(3) "Off"
}


What is happening here? Bugs in
apache
/
phpinfo()
?

Answer

The problem is, that when PHP is loaded via apache, the extension_dir is apparently read relative to the apache server root dir.

But, starting from command line, it is read relative to the PHP root dir.

Thus, despite it being the same loaded php.ini, because I set the extension dir as ext instead of F:\PHP\5.4\ext, apache (or rather: PHP) searched for it in F:\Apache\2.4\ext, which it didn't find for obvious reasons.

Setting the extension_dir to an absolute folder solved the issue. Now apache and cmd both load the exact same configuration, including all extensions (which is exactly how I wanted it).