php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #41444 Version specific php.ini files
Submitted: 2007-05-19 21:29 UTC Modified: 2012-02-25 09:55 UTC
From: geoff dot garside at openhosting dot co dot uk Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 4.4.7 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: geoff dot garside at openhosting dot co dot uk
New email:
PHP Version: OS:

 

 [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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-19 21:39 UTC] geoff dot garside at openhosting dot co dot uk
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);
 [2012-02-25 09:55 UTC] rasmus@php.net
People do this with separate ini directories these days.
 [2012-02-25 09:55 UTC] rasmus@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun May 04 09:01:28 2025 UTC