PHP: declare a class variable to be a stdClass object

beellord

New Member
This is probably pretty simple but I haven't been able to figure out how to phrase the question for Google, so here goes:So, I often do something like this...\[code\]class foo { private $bar = array();}\[/code\]... to set some class property to be an array. However, I'd like to make a private property an object instead, something like this:\[code\]class foo { private $bar = new stdClass();}\[/code\]I tried several variations of this and none of them worked. Can this be done? For bonus points can you assign a private property to be any other class of object?Thanks!
 
Back
Top