PHP object class variable
Posted
by mck89
on Stack Overflow
See other posts from Stack Overflow
or by mck89
Published on 2009-09-03T08:46:55Z
Indexed on
2010/05/21
2:40 UTC
Read the original article
Hit count: 260
I have built a class in PHP and I must declare a class variable as an object. Everytime I want to declare an empty object I use:
$var=new stdClass;
But if I use it to declare a class variable as
class foo
{
var $bar=new stdClass;
}
a parse error occurs. Is there a way to do this or must I declare the class variable as an object in the constructor function?
PS: I'm using PHP 4.
© Stack Overflow or respective owner