I used use the keyword \"use\" generally above the class definition. Like this:
You can not import class with use
keyword. You have to use include
/require
statement. Even if you use some php auto loader, still autoloader will have to use either include
or require
internally.
The Purpose of use keyword:
Consider a case where you have two classes with same name; you'll find it strange, but when you are working with big MVC structure, this happens. So if you have two classes with same name, put them in different name spaces. Now consider when your auto loader is loading both classes (does by require
), and you are about to use object of class. In this case, the compiler will get confused which class object to load among two. To help the compiler make a decision, you can use the use
statement so that it can make a decision which one is going to be used on.
Here refer this How does the keyword 'use' work