We've all seen this error before:
Warning: require_once(test/blah.inc) [function.require-once]: failed to open stream: No such file or directory in /home/narf/narf.inc on line 3 Fatal error: require_once() [function.require]: Failed opening required 'test/blah.inc' (include_path='.:/usr/lib64/php:/usr/lib/php:/home/narf/inc:/home3/narf/php:/home3/narf/inc/dev:') in /home/narf/narf.inc on line 3
Here's what I'm looking for: Some sort of PHP snippet that will list the paths that are being searched for the include file.
From what I can see, I've set up my path correctly (the above include scenario is simply a fabrication), and I can include the file successfully from other portions of the project.
However, I just can't get it to work. If I had a list of locations that were being searched, I could easily track down the path that I'm missing and identify why my require/include isn't working.
Thoughts? Does someone have a snippet kicking around they could share?
Thanks a million in advance! :)
Edit: For what it's worth, I think I tracked down the problem, but if you've still got something that could help out, it would be great for future misconfigurations! :)
Edit 2: Thanks for all who have answered. Getting the include path is nice, but I'm looking for actual absolute paths of directories that are being searched. The reason why I'm being picky is because it gets confusing when using a require() or include() along with relative paths. Also, I suspect that there are some other gotchas such as (potentially) whether or not symlinks are followed on a given setup, etc.
Quoting the manual's page of
Files are included based on the file path given or, if none is given, the
If the file isn't found in the
include()will finally check in the calling script's own directory and the current working directory before failing
include_path is a configuration directive that (quoting) :
Specifies a list of directories where the
file_get_contents()functions look for files.
It can be configured in your
php.ini file, or at runtime, using the
And, of course, to get the include path, you have
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki