If I have an empty include_path
in PHP (like include_path=:
), my include
and require
functions still work. It is like include
tries the initial script's directory first, regardless of what your include_path
is set to.
This gets more confusing to me when I set the include_path
to something like /usr/lib/php5/
, and then try to include('test.php')
from a script that has no test.php
in the same directory. I would imagine it would look for test.php
in my specified include_path
if it wasn't present in the current directory.
I am not looking for a solution; I can already solve my current problem. I am looking for an explanation as to how include_path
works. Thanks!
basically if you just speicfy the name of the file to be included without any path info then then include_path will be used.
ie
include 'wow.php'; (this will use include_path to try to find it)
if it cant find it then it will look in the same directory as the file that tried to include it.
include '/blah/wow.php';
because this has some path info in it then it will ignore include_path all together.
用这个
include($_SERVER['DOCUMENT_ROOT'].'/test.php');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.