Background: Scan all of the classes that inherit a base class under a folder (including subfolders), then include in, instantiate calls to a method, save the data in the database!
Problem: Assuming that there are classes of the same class name under two different subfolders, this time the include will be problematic, and PHP should be confused when new
Beginner, ask aunt.
Reply to discussion (solution)
Yes! There will be problems
So PHP 5.3 introduced the concept of a "namespace"
Classes with the same name in different namespaces do not collide
Yes! There will be problems
So PHP 5.3 introduced the concept of a "namespace"
Classes with the same name in different namespaces do not collide
Then I will be confused when new, because the class name of the two class is the same, there are the same method, that is, I can specify namespace when new?
Yes, you can specify namespace when new.
Namespace.ClassName = new Namespace.ClassName