views:

565

answers:

3

if I call php's parse_ini_file("foo.ini"), in what paths does it look for foo.ini ? the include path? the function's documentation doesn't mention it.

A: 

I would imagine it only looks in the current working directory - See http://uk3.php.net/manual/en/function.getcwd.php if you want to know what that is.

You can always find a path relative to your application by basing it on $_SERVER['DOCUMENT_ROOT']

Paul Dixon
+1  A: 

It could depend on your config but mostly it's current directory and then include_path

Ilya Kochetov
+5  A: 

The filename argument for parse_ini_file is a standard php filename, so the same rules will apply as opening a file using fopen.

You must either specify an absolute file path ("/path/to/my.ini") or a path relative to your current working directory ("my.ini"). See getcwd for your current working directory.

Unlike the default fopen command, if a relative path is specified ("my.ini") parse_ini_file will search include paths after searching your current working directory. I verified this in php 5.2.6.

Devon