search

Home  >  Q&A  >  body text

Why do anonymous functions intelligently call static methods of a class?

// Class
class demos
{
public static function getMethod()
{
return 'The method is:'.__METHOD__;
}

public function getAge(){
return 28;
}
}

// You can call methods in the class
echo call_user_func(['demos','getMethod']) .'<hr>';
//The public method cannot be called
echo call_user_func(['demos','getAge']);

JasonKimJasonKim2113 days ago850

reply all(0)I'll reply

No reply
  • Cancelreply