#28819 [Opn]: parse_ini_file() should look in include_path

From: Date: Thu, 17 Jun 2004 22:17:06 +0000
Subject: #28819 [Opn]: parse_ini_file() should look in include_path
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-61041@lists.php.net to get a copy of this message
ID: 28819 Updated by: edink@php.net Reported By: kmsluder at optonline dot net Status: Open Bug Type: Feature/Change Request Operating System: Irrelevant PHP Version: 4.3.7 New Comment: You can easily do this by: $ini = parse_ini_file(dirname(__FILE__).'/config.ini'); line in your ServerRoot/inc/include.inc file. But perhaps it would be a good idea to add an optional parameter to parse_ini_file() to indicate wheather to use include_path. Previous Comments: ------------------------------------------------------------------------ [2004-06-17 17:49:08] kmsluder at optonline dot net Description: ------------ When keeping include files separate from publicly accessible documents, paths to access files in the includes directory can differ for different pages in the site. For example, on my setup I keep my site in /var/www; publicly-accessible pages (including my PHP pages) are in /var/www/pub (which is Apache's ServerRoot), and the include file is in /var/www/inc. Also stored in /var/www/inc are ini files my PHP application uses. /var/www/inc is in my include_path. In my PHP pages, I use require('include.inc'). Inside include.inc there are calls to parse_ini_file() to process my ini files. Since my ini files are stored in the same directory as my include file, I figured at first that referencing them as simple 'config.ini' etc. would work. Unfortunately, it doesn't, as it looks in the directory of the currently-executing script. Wouldn't it be more logical for parse_ini_file() to look in include_path instead, considering 1) almost any sane include_path includes ./ anyway, and 2) common sense dictates that ini files should be kept out of the ServerRoot, and it makes sense to put them with the other files that should be kept out of the ServerRoot, your include files? Reproduce code: --------------- File: ServerRoot/pub/test.php ============================= <?php include('include.inc'); ?> File: ServerRoot/inc/include.inc ================================ <?php $ini = parse_ini_file('config.ini'); echo $ini['value']; ?> File: ServerRoot/inc/config.ini =============================== value=hi Expected result: ---------------- hi Actual result: -------------- Warning: parse_ini_file(): Cannot open 'config.ini' for reading in ServerRoot/include.inc on line 1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28819&edit=1

« previous php.bugs (#61041) next »