Caller class name

Hi guys,

I’m having trouble on PHP version 5.2 with this issue :


class A {
   public static function find() {
      $table = self::table();
   }

   private static function table() {
      return Table::load(get_called_class());
   }
}

class Table {
  public static function load() {}
}


// name of this classes is db table name
class Something extends A {}
class SomethingElse extends A {}

Something::find();
SomethingElse::find();

and this is working like charm!

Now on PHP version 5.2 get_called_class is not working, and i’m having trouble overriding this. Can someone help, grazie !

get_called_class is only available in PHP >= 5.3.0

There are a few suggestions how to write it for lower versions on the manual page for that function though :slight_smile: