【发布时间】:2012-05-19 11:57:49
【问题描述】:
我在命名空间和use 语句方面遇到了一些问题。
我有三个文件:ShapeInterface.php、Shape.php 和 Circle.php。
我正在尝试使用相对路径来执行此操作,因此我已将其放入所有类中:
namespace Shape;
在我的圈子课程中,我有以下内容:
namespace Shape;
//use Shape;
//use ShapeInterface;
include 'Shape.php';
include 'ShapeInterface.php';
class Circle extends Shape implements ShapeInterface{ ....
如果我使用 include 语句,我不会收到任何错误。如果我尝试use 语句,我会得到:
致命错误:在中找不到类“Shape\Shape” /Users/shawn/Documents/work/sites/workspace/shape/Circle.php 在第 8 行
有人可以就这个问题给我一些指导吗?
【问题讨论】:
-
也关于这个主题 - stackoverflow.com/questions/33341955/…
标签: php namespaces