how to get private properties of an object

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kc11
Forum Commoner
Posts: 73
Joined: Mon Sep 27, 2010 3:26 pm

how to get private properties of an object

Post by kc11 »

Hi ,

I am trying to access a private property of and object, but can't get it working. Here is the schema of the object from a var_dump:

[text]
object(RedBean_OODBBean)[34]
private 'null' => null
private 'properties' =>
array
'id' => int 0
'type' => string 'http://xxxxxx
'map' => string 'http://yyyyy

[/text]

how would I get access to for example - id

Thanks in advance,

KC
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: how to get private properties of an object

Post by social_experiment »

Have you tried $this->properties[0] ?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
kc11
Forum Commoner
Posts: 73
Joined: Mon Sep 27, 2010 3:26 pm

Re: how to get private properties of an object

Post by kc11 »

Thanks for looking at it social_experiment,

I added the following code:

Code: Select all

$bean_props=$table1->properties[0] ; // table 1 is my object name
var_dump($bean_props);
Unfortunately, my output is null.

I think this may have something to do with the scope of accessing private object data
Post Reply