get_class (): 获取当前调用方法的类名;
get_called_class():获取静态绑定后的类名;
abstract class dbObject { const TABLE_NAME='undefined'; public static function GetAll() { $c = get_called_class(); return "SELECT * FROM `".$c::TABLE_NAME."`"; } } class dbPerson extends dbObject { const TABLE_NAME='persons'; } class dbAdmin extends dbPerson { const TABLE_NAME='admins'; } echo dbPerson::GetAll()."<br>";//output: "SELECT * FROM `persons`" echo dbAdmin::GetAll()."<br>";//output: "SELECT * FROM `admins`"