PHP:从对象中获取数据

时间:2010-12-08 21:46:16

标签: php object

如何从此对象获取user_nicename

BP_User Object
(
    [data] => stdClass Object
        (
            [ID] => 1
            [user_login] => NICENICE
            [user_pass] => $P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5.
            [user_nicename] => NICENAME
            ...

我在哪里可以找到资源来学习这个?

2 个答案:

答案 0 :(得分:23)

$variable->data->user_nicename

应该有用。

答案 1 :(得分:3)

您也可以通过其他方式进行打印

foreach($result->data as $newdata) //$result is variable that store raw data 
{
printf("name: %s, Pass: %s, nicename: %s <br/>", $newdata->user_login, $newdata->user_pass, $newdata->user_nicename);
}

结果将是

name:NICENICE , Pass:$P$BwLHvV7zxcZZ/zW7MY0NXNSmANP.U5., nicename:NICENAME