看到他人写的一个玩意,也不知是对是错

WBOY
Release: 2016-06-13 12:20:10
Original
855 people have browsed it

看到别人写的一个玩意,也不知是对是错

本帖最后由 tp_2016 于 2015-05-20 11:32:34 编辑 我们知道教科书上教的写类的方法是一个文件中写一个类,而看到别人写的一个工程中把很多类集中在一个php文件中了,这样好吗,是不是违背了教科书上的旨意呢,
我发现,现实中写的玩意和教科书上很多是不一样的。
似乎写教科书的这些人在故意忽弄读者似的,真是另人发指!

------解决思路----------------------
如果类是通过 __autoload 或 spl_autoload 自动加载的,那么每个类一个文件是合适的

将基类和继承类写在一个文件里,有助于类文件的加载
这样不需要到处都是 include,而读取文件也是要花费时间的

当然,按类的继承关系组织目录树,有助于代码的管理和维护
尤其是在使用命名空间的情况下
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
Popular Tutorials
More>
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!