Home >Backend Development >PHP Tutorial >php自动加载实现

php自动加载实现

WBOY
WBOYOriginal
2016-06-20 12:49:06884browse

class Courier{public $name;public function __construct($name){$this->name=$name;}}
自动加载的实现    public function __autoload($calssname){   include strtolower($classname).'.'.'class.php';    }        $a= new Courier('qq');

上面两个文件一个是在 Couerier.class.php文件,里一个是在 qq.php.文件中。

可见当找不到类的时候会自动加载auto load 函数

strtolower  //所有字符串转化为小写


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