#50427 [NEW]: Can't predefine variables as objects inside a class

From: Date: Wed, 09 Dec 2009 15:39:22 +0000
Subject: #50427 [NEW]: Can't predefine variables as objects inside a class
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-145581@lists.php.net to get a copy of this message
From: omri dot rules at gmail dot com Operating system: Windows XP PHP version: 5.3.1 PHP Bug Type: Class/Object related Bug description: Can't predefine variables as objects inside a class 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 bug report at http://bugs.php.net/?id=50427&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50427&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50427&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50427&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50427&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50427&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50427&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50427&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50427&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50427&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50427&r=support Expected behavior: http://bugs.php.net/fix.php?id=50427&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50427&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50427&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50427&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50427&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50427&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50427&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50427&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50427&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50427&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50427&r=mysqlcfg

« previous php.bugs (#145581) next »