开发者

php check if abstract method exists

开发者 https://www.devze.com 2023-01-19 01:32 出处:网络
abstract class A{ abstract test(开发者_如何学C); function __construct (){ //check if test method exists on B//
abstract class A{
   abstract test(开发者_如何学C);
   function __construct (){
       //check if test method exists on B//
   }
}

class B extends A{

}

new B();

my question is ... is there a way to check if the test method exists on class B? so I can avoid the fatal error ?

hope it makes sense.


method_exists(get_called_class(),'test');

the above has solved my problem :) hope it helps someone out there.

0

精彩评论

暂无评论...
验证码 换一张
取 消