带你穿越带你飞~,一秒钟PHP变JS =^ =!!!
程序员文章站
2022-05-28 19:10:52
...
跳至
class testMet { public function __construct(\Closure $method) { $bind = \Closure::bind($method, $this); $bind(); } public function name() { var_dump('Oh, My God'); } } class papa { public function __construct() { $that = $this; (new testMet(function () use($that) { // 注意哦,这里的 $this 就不再是papa类的对象咯,而是testMet构造出来的哦~ $that->_tn('Levi'); $this->name(); })); } protected function _tn($name) { var_dump('I am '.$name); } } class son extends papa { protected function _tn($name) { var_dump('Her is '.$name); parent::_tn('Lucy'); } } new son('Levi');