1

我在本地主机上创建了一个数据类,它使用了 php 5.3 static()get_called_class().

现在我的虚拟主机支持 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] => ...
)

我怎样才能使它名称是用户对象而不是这个?

4

0 回答 0