Is there a way to verify if multiple methods exists in same class?
class A{
function method_a(){}
function method_b(){}
}
if ( (int)method_exists(new A(), 'a', 'b') ){
echo "Method a & b exist";
}
Is there a way to verify if multiple methods exists in same class?
class A{
function method_a(){}
function method_b(){}
}
if ( (int)method_exists(new A(), 'a', 'b') ){
echo "Method a & b exist";
}
I'd probably have used interface here:
interface Foo {
function a();
function b();
}
... then, in the client code:
if (A instanceof Foo) {
// it just has to have both a() and b() implemented
}
I think this more clearly shows your real intent then just checking for methods' existence.