Namespace interface

I have a structure:

/VBAL/ /VBAL/Interface/ /VBAL/Interface/Named.php .... /VBAL/Component.php 

component.php:

 namespace JV\VBAL; class Component implements \JV\VBAL\Interface\Named {} 

Named.php:

 namespace JV\VBAL\Interface; interface Named {} 

But I have a parsing error:

Parse error: syntax error, unexpected '{' waiting for T_STRING or T_NAMESPACE or T_NS_SEPARATOR

What do you call a directory "namespace" or place files?

+4
source share
2 answers

Interface is a reserved word in PHP. You cannot use it as part of your namespace.

+12
source

As mentioned earlier, Interface is a reserved word and cannot be used as part of a name.

Two good alternatives:

Base - in which you can store many base classes from which you extend, for example, interfaces, abstract classes, features

or Interfaces , but this one, in my opinion, is used a little less due to its multiple form

+1
source

All Articles