tags:

views:

105

answers:

5

I am running following code, getAccount() is a static function,

$ac_info = AccountClass::getAccount($ac_code);
print_r($ac_info);

and getting following output

AccountClass Object ( [account_code] => [email protected] [username] => XYZ [email] => [first_name] => [last_name] => [company_name] => [id] => [email protected] [balance_in_cents] => 0 [created_at] => 1271333048 [state] => active )

But I want to access the value of "account_code" shown above, how to access it, and AccountClass Object what is this, this is array or what? I am not getting it properly.

Please explain what is AccountClass Object and how to access value of properties account_code, first_name inside this array.

Thanks

+1  A: 

Try this..

$ac_info->account_code
Ian P
+5  A: 

Knock yourself out.

Ignacio Vazquez-Abrams
Prashant, if find it amazing that you have 1000+ points on SO and ask such beginner questions. Makes one wonder has SO rating system gone FUBAR.
Milan Babuškov
Ya that's OK, but I am not an exp. programmer in PHP (OOPS), that's why asked this question. Is there anything wrong?
Prashant
Basic questions such as this are not appropriate for Stack Overflow, and usually indicate that the asker has not spent sufficient (or indeed, any) time reading through documentation and/or tutorials.
Ignacio Vazquez-Abrams
I've seen [worse](http://stackoverflow.com/questions/2800561/position-of-image-not-changing-with-window-scroll/2800592#2800592) [questions](http://stackoverflow.com/questions/2107333/whats-the-name-of-this-operator/2107355#2107355) that could have easily been looked up. @ignacio got 17 up-votes for answering one.
bschaeffer
@bschaeffer: To be fair, I *did* have to really dig to find the second part of that answer.
Ignacio Vazquez-Abrams
+2  A: 

$ac_info is an object of AccountClass class. account_code, username, email, first_name, last_name and all the rest are object properties.

You can access them in a way:

echo $ac_info->account_code;
Tomasz Tybulewicz
+1  A: 

Try also :

print_r(get_class_methods($ac_info));

You will see an array of the methods in the AccountClass class. Because if $account_code is private, you won't be able to read it directly, but you will have to use the getter, something like :

$ac_info->getAccountCode();

mexique1
+1  A: 

Try this..

$ac_info->account_code;

rammsito