The problem with absolute paths in require: constant redefinition, variable overrides, and re-invocation increase overhead.
Because the relative path refers to the total problem, Google uses the absolute path under reference.
Three methods have been tried in absolute path use.
1, define the path constant, re-use path for require operation.
Here, if the Requrie page of the main page has the same define Paht constant, the error repeats defining the constant path.
2, the $path variable, such as the following code, redefine the variable caused by the value of the overwrite, may lead to other related require path error.
The temporary rejection method resets the $path variable as follows, but it feels silly.
3, do not use the Define variable to define the path path, directly require each time the path is reconstructed, such as
Require DirName (__file__). ' File_name.php ';
But it makes people feel stupid ... and repeated calls to dirname increased overhead is uninteresting ... But in the wrong way, at least not wrong.
4, other No, how to better deal with the absolute path of the require, to you for advice.
PHP Code
------Solution--------------------
Unify the rules. The definition of a path constant is not allowed.
Or you can use defined to make judgments. If it is defined, it is no longer defined.
------Solution--------------------
Defines the path constant, which is typically used for single-entry applications
Since the entry program is always run first, there is no problem in defining it here.
For multi-entry applications, the path constant is defined in the Common environment settings file (e.g. config.php)
To prevent problems during multiple loads, it is generally necessary to determine
if (defined (' PATH ')) return;
Define (' PATH ', DirName (__file__));
Load additional files or define code for public classes and functions