Re: Ability to assign new object to a class property.
| From: | Stas Malyshev | Date: | Fri, 13 Apr 2012 20:06:30 +0000 |
| Subject: | Re: Ability to assign new object to a class property. | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-59912@lists.php.net to get a copy of this message | ||
Hi!
> Why can't we create a new object and assign it to property like this?
Because the engine doesn't run code when parsing class definitions so
defaults should be constants (otherwise would also create a lot of
trouble for bytecode caching as object are not cacheable).
Use ctor for complex initializations.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227