|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-05-19 21:29 UTC] geoff dot garside at openhosting dot co dot uk
Description: ------------ Some web hosting companies want to run both PHP 4 and PHP 5 on their servers, In these cases it would be useful for PHP to search for a phpX.ini file where X is the value of the PHP_MAJOR_VERSION. This would make it easier for both server admins as well as clients to create separate configs for different versions of PHP within their websites. I have selected version 4.4.7 as I am required to choose a version, but this should equally pertain to PHP 5.2.2 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 12:00:01 2025 UTC |
I have written a patch which provides this. The patch is against version 4.4.7 and I have a similar one for PHP 5.2.2 if required but the code is the same. I can't see anywhere to simply attach files, so I will paste it here. --- main/php_ini.c.orig 2007-05-14 20:51:28.000000000 +0100 +++ main/php_ini.c 2007-05-14 21:06:20.000000000 +0100 @@ -395,6 +395,17 @@ fh.filename = php_ini_opened_path; } } + /* Search php%PHP_MAJOR_VERSION%.ini file in search path */ + if (!fh.handle.fp) { + const char *fmt = "php%d.ini"; + char *ini_fname = emalloc(strlen(fmt) + 3); /* Should be good until PHP v999.0 */ + sprintf(ini_fname, fmt, PHP_MAJOR_VERSION); + fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); + efree(ini_fname); + if (fh.handle.fp) { + fh.filename = php_ini_opened_path; + } + } /* Search php.ini file in search path */ if (!fh.handle.fp) { fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);