Reputation: 1383
I did a lot of reading but I cannot answer one question I have with php include behavior.
On php.net it says that it looks into the directories that are in include_path variable. After that it looks in the current directory. If I put relative path (starting with dot) or absolute path it ignores the include_path.
So far so good.
I get confused when I see examples on the internet that start with something like that:
include('LibName/SomeFile.php');
Would php take every path from include_path and append 'LibName/SomeFile.php to look for the file? What is the behavior?
Upvotes: 0
Views: 79
Reputation: 1289
PHP considers each entry in the include path separately when looking for files to include. It will check the first path, and if it doesn't find it, check the next path, until it either locates the included file or returns with a warning or an error. You may modify or set your include path at runtime using set_include_path().
You can find more info here: http://www.php.net/manual/en/ini.core.php#ini.include-path
Upvotes: 1
Reputation: 182753
It's exactly what you said it is. It checks each directory in include_path to see if 'LibName/SomeFile.php' references a file relative to those paths. If not, it tries the current directory.
Upvotes: 2