Home >Backend Development >PHP Tutorial >Regarding the issue of automatic loading of namespaces
Running environment description:
Referring to foo.php (file2) in the index.php (file1) file
Problem:
As long as the namespace (namespace testindex) is declared in index.php, an error will be reported.
Running environment description:
Referring to foo.php (file2) in the index.php (file1) file
Problem:
As long as the namespace (namespace testindex) is declared in index.php, an error will be reported.
Because you added the namespace, the function __autoload()
is also applied to this namespace, that is, calling this function becomes testindex__autoload(), then PHP cannot find the function __autoload()
and cannot Complete the automatic loading process.
One is the result of the commented out namespace, and the other is not.
Why does this happen?
//-------------------------------------------------- -------------