A class is written and namespace is used: 'namespaceab; classDemoextendsXXX {code ...}} 'Use in another file: 'useabdemo; $ dnewDemo (); 'prompt: the XXX class cannot be found. My own class uses the namespace. The inherited XXX class belongs to the... class and uses the namespace :'
Namespace a \ B;
Class Demo extends XXX {
……
}'
In another file :'
Use a \ B \ Demo;
$ D = new Demo ();
`
Tip: the XXX class cannot be found.
My own class uses the namespace. The inherited XXX class belongs to a third-party class library. The third-party class library does not use the namespace and uses the require_once file.
I don't know how to solve this problem. It's unrealistic to change all third-party class libraries to namespaces. I can't do this whenever I use a third party. The amount of work is huge.
Reply content:
A class is written and namespace is used :'
Namespace a \ B;
Class Demo extends XXX {
……
}'
In another file :'
Use a \ B \ Demo;
$ D = new Demo ();
`
Tip: the XXX class cannot be found.
My own class uses the namespace. The inherited XXX class belongs to a third-party class library. The third-party class library does not use the namespace and uses the require_once file.
I don't know how to solve this problem. It's unrealistic to change all third-party class libraries to namespaces. I can't do this whenever I use a third party. The amount of work is huge.
A. php
'; }}
C. php
'; }}
B. php
out();
Which probably means it?
If no namespace is set for a third-party class, a top-level namespace '\' is added by default to PHP.
By the way, pay attention to the file loading sequence.
class Demo extends \XXX
1. The XXX class and the class to be used in this class must be added with namespace
2. The code must be modified:
Namespace a \ B; use path/XXX; // here, the class inherited by XXX must be imported into class Demo extends XXX {…} using the use Operator {......} '
These two conditions are indispensable !!!