I use several require () statements on my site. Some of them require assertions; additional require elements are added. The problem that I sometimes encounter is that the directory that requires the first request may be different from the second and, in turn, forces the site to look in the wrong place.
For example:
Suppose the site structure has two main folders: X and Y. Y has a subfolder named Z.
The file in the X folder called page.php uses the require statement for the file in Y called 'function.php'. However, Function.php uses an additional require request in Z called 'constants.php'.
page.php (inside X) looks like this:
required ('../Y/function.php');
and function.php (inside Y) looks like this:
required ('Z / constants.php');
The problem I am facing is that when X essentially tries to call the Z-const file, it treats it as if the Z folder was placed in its own subdirectory.
i.e. page.php does 2 requires the required calls ('../Y/function.php'); and require ('Z / constants.php'); <- which does not exist.
I know that I can use absolute paths, but I constantly switch between windows and Linux environments, and it will be a giant PITA to go back and forth between these two formats.
Any suggestions?
EDIT
The strangest part, sometimes the problem is higher. I canβt understand why itβs pretty much the same, but it seems that the problem may be that forward directories can be automatically corrected, but go back (that is, being at level 3 in the same folder and jumping back causes problems)
php
Jm4
source share