I have a file test.php
in the folder myfolder
. myfolder
also contains another folder called inner
.
Both myfolder
and inner
contain a file called msg.php. The entire layout looks like this:
- myfolder
- test.php
- inner
- msg.php
- msg.php
In test.php
, I've set the include_path to ./inner
and included the file msg.php
:
<?php
error_reporting(E_ALL | E_STRICT);
ini_set("include_path", "./inner");
echo ini_get('include_path'); // shows ./inner
include("msg.php"); // outputs hello from myfolder/inner/msg.php
?>
However, if I modify the working directory to ./inner
, myfolder/msg.php
will be included instead of myfolder/inner/msg.php
:
<?php
error_reporting(E_ALL | E_STRICT);
ini_set("include_path", "./inner");
echo ini_get('include_path'); // shows ./inner
chdir('./inner');
include("msg.php"); // outputs hello from myfolder/msg.php
?>
Shouldn't the second piece of code include myfolder/inner/msg.php
instead of myfolder/msg.php
?