spl_autoload_register[$this, autoload]
我的疑问:
spl_autoload_register([$this, 'autoload']) 平时见的都是$this-> ,写成这样[$this, autoload]该怎么理解
可以理解成spl_autoload_register([$this->autoload) 吗
[$this, autoload] 这个数组
是__aotuload这个魔术方法的变体写法吗
感谢学习群的 Find老师 详细的解答
示例
class test{
public static function loadprint($class){
$file = $class . '.class.php';
if(is_file($file)){
require_once($file);
}
}
}
spl_autoload_register( array('test', 'loadprint') );
//另一种写法:spl_autoload_register( "test::loadprint");
$obj = new PRINTIT();
$obj->doprint();

浙公网安备 33010602011771号