开发者

PHP object data

can someone tell me how to get the e.g Firstname or Email value from this array?

Array
(
    [0] => User Object
        (
            [UserId:UserData:private] => 1
            [Enabled:UserData:private] => 1
            [RbComms:UserData:private] => 0
            [UserLevel:UserData:private] => Admin
            [Password:UserData:private] => 098f6bcd4621d373cade4e832627b4f6
            [IP:UserData:private] => 
            [BalanceReminder:UserData:private] => 0
            [ThirdpartyComms:UserData:private] => 0
            [CreationTime:UserData:private] => 2011-07-04 14:04:00
            [Browser:UserData:private] => 
            [Email:UserData:private] => admin@admin.com
            [Username:UserData:private] => admin
            [Mobile:UserData:private] => 5465651651
            [Latitude:UserData:private] => 
            [Firstname:UserData:private] => Admin
            [Lastname:UserData:private] => Henderson
            [Lo开发者_JAVA百科ngitude:UserData:private] => 
            [Balance:UserData:private] => 0.00
        )


They are private members, so you need to use the User class' methods to get at them.

These are usually something like $myuser->getEmail(), but it depends on how it is defined in the class. Read its source code to find out.


You should do:

$the_array[0]->Firstname 

or

$the_array[0]->Email

Hope this helps. Cheers


echo $array[0]->Firstname; 

or, more properly:

foreach ($array as $user)
{
    echo $user->Firstname;
}

Edit: Brad's answer is also correct, as these are private variables, the class should also provide "get" methods, such as

$array[0]->GetFirstname(); 


Interesting syntax. I'd try this:

 var_dump( $array[0]->Email ); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜