您好,欢迎访问一九零五行业门户网

.net - php如何实现C#那种类库的概念

如下文件内容。
tool1.phpnamespace mytools;class tool1{}

tool2.phpnamespace mytools;class tool2{}

u.phpinclude mytools\tool1;include mytools\tool2;$t1 = new tool1();$t2 = new tool2();

现在想实现的效果是,可以好像c#那样写,例如
include mytools;$t1 = new tool1();$t2 = new tool2();

目的就是,如果命名空间一样的话,则只需要引用一次,就可以使用里面多个类,应该怎么写。。。?
回复内容: 如下文件内容。
tool1.phpnamespace mytools;class tool1{}

tool2.phpnamespace mytools;class tool2{}

u.phpinclude mytools\tool1;include mytools\tool2;$t1 = new tool1();$t2 = new tool2();

现在想实现的效果是,可以好像c#那样写,例如
include mytools;$t1 = new tool1();$t2 = new tool2();

目的就是,如果命名空间一样的话,则只需要引用一次,就可以使用里面多个类,应该怎么写。。。?
自动加载啊。。。
class
其它类似信息

推荐信息