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();

 

posted @ 2019-09-22 01:19  runde  阅读(155)  评论(0)    收藏  举报