I know theres a method_exists() but it says true even when that method is inherited.
class A
{
public function eix()
{
}
}
class B extends A
{
}
echo method_exists (‘B’, ‘eix’);
so its true, but B class doesnt have it. How to dodge this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ll need to use reflection to achieve this. Look into the
ReflectionMethodclass and you’ll find thegetDeclaringClassmethod.That said, the key point is that class
Bdoes have a methodeix, since it inherits allA‘s methods that it doesn’t redefine. I can’t quite work out a circumstance where you’d need to know where the method was defined, but this technique allows you to do so if necessary.