简而言之,我将一个用户 ID 传递给一个函数并尝试获取该用户的所有属性:
$user = \Sitename\UsrManager::getUserById($user_id);
然后我print_r($user)
得到一堆数据:
Sitename\User Object ( [model:protected] => User Object ( [errors] => [attributes:ActiveRecord\Model:private] => Array ( [user_id] => 18 [company_name] => ABC Ltd [company_logo] => logo.png [brief] => Sample text [profile] => Some Profile ) [__dirty:ActiveRecord\Model:private] => Array ( ) [__readonly:ActiveRecord\Model:private] => [__relationships:ActiveRecord\Model:private] => Array ( ) [__new_record:ActiveRecord\Model:private] => ) [_password_updated:Sitename\User:private] => [template:protected] =>
如果我想获取特定属性,例如Company Name,我尝试将公司名称回显为$user->company_name
,但没有什么可显示的,在我的示例中调用 data(object?) 的正确方法是什么?这就像调用必要数据的旧方法一样$row['company_name']
。