开发者

Namespace interface

开发者 https://www.devze.com 2023-03-26 17:45 出处:网络
I have struct: /VBAL/ /VBAL/Interface/ /VBAL/Interface/Named.php .... /VBAL/Component.php Component.php: namespace JV\\VBAL;

I have struct:

/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开发者_Python百科 JV\VBAL\Interface;
interface Named {}

But I've got parse error:

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

How do you call the directory "namespace", or place the files?


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


As mentioned before Interface is reserved word and can not be used as part of namepsace.

Two good alternatives are:

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

or Interfaces, but this one is in my opinion used little less because of it's plular form

0

精彩评论

暂无评论...
验证码 换一张
取 消