The_Unknown
The_Unknown

Reputation: 1048

Is it ok to use the "use"-statement in non-class PHP files?

the title says it all. Is it ok to do something like:

<?php

use Some\Very\Long\Namespace\SomeClassName;

SomeClassName::someMethod();

Or does this somehow negatively affect the class loader?

Upvotes: 2

Views: 128

Answers (1)

deceze
deceze

Reputation: 522066

All use does is alias a long namespaced name to a different (shorter) local name. Your code is exactly equivalent to:

Some\Very\Long\Namespace\SomeClassName::someMethod();

So yes, it's perfectly fine.

Upvotes: 4

Related Questions