phpfileparsingpathini

PHP parse_ini_file() - where does it look?


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.


Solution

  • 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.