【发布时间】:2015-02-06 08:41:39
【问题描述】:
我有两节课。命名空间 test\bout\ 中的 Bout,命名空间 test\art 中的 Art。
namespace test\bout;
use test\art\Art;
class Bout extends Art{
function __construct(){
include_once 'Art.php';
echo"boutique ";
new Art();
}
}
new Bout();
然后:
namespace test\art;
class Art{
function __construct(){
echo "article";
}
}
只要我输入“扩展艺术”,我就有:致命错误:第 4 行的 /opt/lampp/htdocs/test/Boutique.php 中找不到类 'test\art\Art'
这是否意味着我没有使用“use test\art\Art;”正确吗?
谢谢
【问题讨论】:
-
可能你没有类加载器或者你的文件夹架构无效并且不响应命名空间
-
您是否真的包含定义
test\art\Art的文件之前class Bout extends ..?
标签: php namespaces extends