Blogger Information
Blog 57
fans 0
comment 0
visits 46944
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
类的自动加载
藍錄的博客
Original
691 people have browsed it

实例

<?php
/**
 * 类的自动加载
 */
//include './class/Demo1.php';
//include './class/Demo2.php';


spl_autoload_register(function ($className){
    require './class/'.$className.'.php';
    //存在命名空间的情况下

//    $className = str_replace("\\","/", $className);
//    require './class/'.$className.'.php';
});

echo Demo1::CLASS_NAME, '<hr>';
echo Demo2::CLASS_NAME, '<hr>';

运行实例 »

点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post