I am really confused about PHP and the path system.
I have this structure:
- Includes
- Login
- View
* Secure
These are all director
There are two types of paths: relative, and absolute. Absolute paths start with a /..
(or C:/..
or however that works on Windows) and always unequivocally point at one specific file.
Relative paths (not starting with /
) are relative to the include_path
variable. That's a variable that contains a bunch of folders, where PHP will look for your relative path. That include_path
also includes .
, the current directory. The "current" directory depends on which file was the "first" to be executed. So it varies depending on which file starts to include
others.
Better: construct absolute paths:
include __DIR__ . '/../Login/file.php';
This is always relative to the directory the file is in.