我有这个简单的一行代码:
$thisUserName = is_array($user) ? $user->name : $user;
在这里,$thisUserName
是给的$user
, 意味着条件is_array
返回假, 即使print_r
表明那$user
是一个数组。
任何想法,任何人?
谢谢。
PS。我尝试将其更改为echo is_array($user) ? 'yes' : 'no'
,但它没有回应。
编辑:
print_r($user) 给出
stdClass Object
(
[id] => 169
[name] => Cedric
[username] => pulpfiction
[email] => xxx@gmail.com
[password] => c22601b4ed1ac11a80955d6c0eeb1933
[password_clear] =>
[usertype] => Registered
[block] => 0
[sendEmail] => 0
[gid] => 18
[registerDate] => 2013-01-30 11:12:10
[lastvisitDate] => 2013-02-24 19:45:45
[activation] =>
[params] =>
[aid] => 1
[guest] => 0
)