Reputation: 5473
I have file 1.php having a require_once for 2.php (both of them are in different folders). The issue I am having is that 1.php seems to magically include 2.php since the path for 2.php is not in 1.php. Just to be sure, I even added a set_include_path('.') before the require_once '2.php', but it still works... Is there something obvious I am missing or is this plain weird??
Edit:
//-- file 1.php
//-- long list of requires...
set_include_path('.');
echo get_include_path();
require_once '2.php';
The above works fine while 1.php and 2.php are in different folders.
Upvotes: 1
Views: 1191
Reputation: 158005
There is some include magic in PHP, i've met it before.
Something autoload related, I believe.
It always looks in the folder where file with running class resides
Upvotes: 2
Reputation: 11612
Perhaps you have a file with the same name as file 2 in the path of file 1.
Upvotes: 1
Reputation: 26766
For the sake of argument, if you put a 2.php in the same location as 1.php does the new file get included instead of the old one?
Can you tell use what the value of your open_basedir
is?
Upvotes: 1
Reputation: 96199
Long shot but maybe one of the other included files changed the current working directory:
<?php
echo 'cwd at the beginning of 1.php: ', getcwd(), "\n";
//-- file 1.php
//-- long list of requires...
set_include_path('.');
echo 'include_path: ', get_include_path(), " \n";
echo 'cwd: ', getcwd(), "\n";
require_once '2.php';
Upvotes: 1
Reputation: 5878
Try echo get_include_path()
after you set your empty include path, it may be set somewhere else (like in the web server config file).
Upvotes: 1