Let's say that we have a file named "include.php" in a directory, "includes", and this file includes another file, "manager.php", from a sub directory, "objects",
include "objects/manager.php";
now "manager.php" is a class names "manager" that has a function that does an include:
public function includeDBObject()
{
include "databaseobjects/mysql.php";
}
This include is another class, "mysql class", that has the following contents:
public $name = "I am in the MySql class";
public function getName()
{
return $this->name;
}
Now back to the original include, "include.php", the contents are as follows
include "objects/manager.php";//as shown above
$a = new manager;
$a->includeDBObject();
$b = new mysql;
echo $b->getName();
The result of this is: "I am in the MySql class."
Shouldn't the $a->includeDBObject trigger an error of not being able to find the file as the specified directory is incorrect with relation to where "include.php" is located?
According to the php documentation the include does: "The include statement includes and evaluates the specified file."
http://php.net/manual/en/function.include.php
so since manager.php is included the directory in its include function should throw an error as it is "included" in a different directory.
Any explanation would help with references to documentation.
Thanks