Reputation: 7955
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.
Upvotes: 3
Views: 3811
Reputation: 2837
By reading the official documentation one can assume that if a relative path is used the file is searched in
But one can provide an absolute path, starting with '/' on *nix or "c:/" on a windows installation.
Read php.net on parse_ini_file
for more tips
Upvotes: 0
Reputation: 5784
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.
Upvotes: 6
Reputation: 18463
It could depend on your config but mostly it's current directory and then include_path
Upvotes: 1
Reputation: 300975
I would imagine it only looks in the current working directory - See https://www.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']
Upvotes: 1