php check if method overridden in child class php check if method overridden in child class php php

php check if method overridden in child class


Check if the declaring class matches the class of the object:

$reflector = new \ReflectionMethod($ob, 'createTable');$isProto = ($reflector->getDeclaringClass()->getName() !== get_class($ob));

PHP Manual links:


To get this information, you have to use ReflectionClass. You could try getMethod and check the class name of the method.

$class = new ReflectionClass($this);$method = $class->getMethod("yourMethod");if ($method->class == 'classname') {    //.. do something}

But keep in mind, that reflection isn't very fast, so be careful with usage.