我在我的localhost上创建了一个数据类,它使用了来自php 5.3,static()或get_called_class()的新功能;
现在我的webhost支持php 5.2,我不得不尝试别的东西,所以我尝试了这个:
public static function get_called_class()
{
$objects = array();
$traces = debug_backtrace();
foreach ($traces as $trace)
{
if (isset($trace['object']))
{
if (is_object($trace['object']))
{
$objects[] = $trace['object'];
}
}
}
if (count($objects))
{
return get_class($objects[0]);
}
}
结果差不多,除了我得到这个对象名称:
[__PHP_Incomplete_Class_Name] => user
[table] => user
[data:private] =>
[className:private] => user
[arFields:private] => Array
(
[id] => id
[firstname] => firstname
[initials] => initials
[lastname] => lastname
[email] => email
[password] => password
)
[id] => 15
[firstname] => ...
[initials] => ...
[lastname] =>...
[email] => ...
[password] => ...
)
我怎样才能使名称是用户对象而不是这个?
谢谢!