Home >Backend Development >PHP Tutorial >autoload - PHP类库几十个怎样才能防止类重复加载

autoload - PHP类库几十个怎样才能防止类重复加载

WBOY
WBOYOriginal
2016-06-06 20:47:131358browse

说是 include_once require_once 效率很低

然后用 spl_autoload_register 好像也要做很多的判断

有什么办法能解决呢?

回复内容:

说是 include_once require_once 效率很低

然后用 spl_autoload_register 好像也要做很多的判断

有什么办法能解决呢?

Laruence曾经在博客上解释过,以及解决方法
http://www.laruence.com/2012/09/12/2765.html

可参考psr-0命名标准并结合spl_autoload_register实现类自动加载
具体实现参考composer的ClassLoader类

Statement:
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