#50427 [Opn->Bgs]: Can't predefine variables as objects inside a class

From: Date: Wed, 09 Dec 2009 18:08:52 +0000
Subject: #50427 [Opn->Bgs]: Can't predefine variables as objects inside a class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-145584@lists.php.net to get a copy of this message
ID: 50427 Updated by: rasmus@php.net Reported By: omri dot rules at gmail dot com -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Windows XP PHP Version: 5.3.1 New Comment: Please read: http://php.net/manual/en/language.oop5.properties.php Previous Comments: ------------------------------------------------------------------------ [2009-12-09 15:39:21] omri dot rules at gmail dot com Description: ------------ I've tried to predefine a variable inside a class as an instance of another class. The result was a parse error. Reproduce code: --------------- <?php class Foo { public $var = 1; } class Bar { public $obj = new Foo; public function __construct() { echo $this->obj->var; } } $a = new Bar; ?> Expected result: ---------------- 1 Actual result: -------------- Parse error: parse error in C:\wamp\www\try.php on line 7 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50427&edit=1

« previous php.bugs (#145584) next »