0

Is something like this possible?

<?
class A
{
   public static function fun()
   {
      var_dump(get_class(child)); //bool(false) //should return B
   }
}
class B extends A
{
   public static function fun()
   {
      parent::fun();
   }
}

B::fun();
?>
0

2 Answers 2

2
<?php
class B extends A
{
   public static function fun()
   {
      parent::fun();
   }
}
class A
{
   public static function fun()
   {
      var_dump(get_called_class());
   }
}

B::fun();

http://php.net/manual/en/function.get-called-class.php

Sign up to request clarification or add additional context in comments.

Comments

2

As of PHP 5.3, there is get_called_class() for this purpose:

echo get_called_class(); // yields "B"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.