Ability to assign new object to a class property.

From: Date: Fri, 13 Apr 2012 19:19:28 +0000
Subject: Ability to assign new object to a class property.
Groups: php.internals 
Request: Send a blank email to internals+get-59902@lists.php.net to get a copy of this message
I always wondered why can't we do something like this in php class MyClass{ private $storage = new ArrayObject(); public function __construct($v){ // whatever } // rest of class } Why can't we create a new object and assign it to property like this? Then when a new instance of MyClass is created the $storage variable is automatically assigned a new ArrayObject. Somethink like this is valid, possible and commonly used in Java, why not in php? Has anyone already asked for this to be valid syntax in php? Dmitri Snytkine Web Developer Ultra Logistics, Inc. Phone: (888) 220-4640 x 2097 Fax: (888) 795-6642 E-Mail: dsnytkine@ultralogistics.com Web: www.ultralogistics.com "A Top 100 Logistics I.T. Provider in 2011"

« previous php.internals (#59902) next »