Regarding the issue of automatic loading of namespaces

WBOY
Release: 2023-03-01 20:16:01
Original
1060 people have browsed it

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.

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Reply content:

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.

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

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?
//-------------------------------------------------- -------------
Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Regarding the issue of automatic loading of namespaces

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!