我在命名空間和use
語句中遇到了一些問題。PHP名稱空間和「use」
我有三個文件:ShapeInterface.php
,Shape.php
和Circle.php
。
我試圖做到這一點使用相對路徑,所以我已經把這個所有類:
namespace Shape;
在我的圈子裏I類有以下幾點:
namespace Shape;
//use Shape;
//use ShapeInterface;
include 'Shape.php';
include 'ShapeInterface.php';
class Circle extends Shape implements ShapeInterface{ ....
如果我使用include
聲明我沒有得到任何錯誤。如果我嘗試use
語句,我得到:
Fatal error: Class 'Shape\Shape' not found in /Users/shawn/Documents/work/sites/workspace/shape/Circle.php on line 8
可能有人請給我在這個問題上一些指導?
我讀這一點,還是不太明白這一點。外部文件是否包含在使用中? –
也關於這個問題 - http:// stackoverflow。com/questions/33341955 /不要導入或使用順序影響功能在php – Peter