views:

21

answers:

1

Hi,

I don't think I am being silly here.

class Parent {
  function load($function) {
    if (method_exists(__CLASS__, $function)) {
      // Load Function
    }
  }
}

Class Child extends Parent {
  function foo() {
  }
}

$this->Child->load('foo');

The problem is that __CLASS__ is returning 'Parent'. How do I get it to return Child?

+2  A: 

The direct answer to your question would be use get_class():

if (method_exists(get_class($this), $function)) {

but in your case, why not simply use $this as a parameter to method_exists()?

if (method_exists($this, $function)) {
Pekka
Ah yes of course. Thank you very much for the help. Will tick in 9 minutes.
JasonS