您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 随州分类信息网,免费分类信息发布

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

2024/6/19 7:04:53发布11次查看
如下文件内容。
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
随州分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录