Possible Duplicate:
Instance as a static class property
I got a problem about creating an Object in a class as an attribute.
include 'Bar.php';
class Foo()
{
private $bar = new Bar();
}
It comes out a parse error. But when I put the $bar outsite class
include 'Bar.php';
class Foo()
{
//private $bar = new Bar();
}
$bar = new Bar();
No syntax error. works perfectly. So what's the problem. I just ported my Java knowledge to PHP. Sometimes, its so confusing.