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

WBOY
Release: 2016-06-06 20:20:56
Original
1075 people have browsed it

如下文件内容。

tool1.php

namespace MyTools; class tool1 { } 
Copy after login
Copy after login

tool2.php

namespace MyTools; class tool2 { } 
Copy after login
Copy after login

u.php

include MyTools\tool1; include MyTools\tool2; $t1 = new tool1(); $t2 = new tool2(); 
Copy after login
Copy after login

现在想实现的效果是,可以好像C#那样写,例如

include MyTools; $t1 = new tool1(); $t2 = new tool2(); 
Copy after login
Copy after login

目的就是,如果命名空间一样的话,则只需要引用一次,就可以使用里面多个类,应该怎么写。。。?

回复内容:

如下文件内容。

tool1.php

namespace MyTools; class tool1 { } 
Copy after login
Copy after login

tool2.php

namespace MyTools; class tool2 { } 
Copy after login
Copy after login

u.php

include MyTools\tool1; include MyTools\tool2; $t1 = new tool1(); $t2 = new tool2(); 
Copy after login
Copy after login

现在想实现的效果是,可以好像C#那样写,例如

include MyTools; $t1 = new tool1(); $t2 = new tool2(); 
Copy after login
Copy after login

目的就是,如果命名空间一样的话,则只需要引用一次,就可以使用里面多个类,应该怎么写。。。?

自动加载啊。。。

class
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!