这样的事情可能吗?
<?
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();
?>
自 PHP 5.3 起,有用get_called_class()
于此目的:
echo get_called_class(); // yields "B"
<?php
class B extends A
{
public static function fun()
{
parent::fun();
}
}
class A
{
public static function fun()
{
var_dump(get_called_class());
}
}
B::fun();