Difference between #6 and #7 of
Understanding Virtual Attributes and get/set methods

Revision #7 has been created by qiang on Apr 6, 2011, 12:18:02 AM with the memo:

« previous (#6) next (#8) »

Changes

Title unchanged

Understanding Virtual Attributes and get/set methods

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

Virtual Attributes; __get; __set

Content unchanged

[...]
But because of Yii's implementation of `__get/set`, these will not work because the low-level methods in `CComponent` throw an exception for an unknown attribute rather than let it fall through (which would enable dynamic attributes).

Some question the wisdom of blocking this, though others may well appreciate the safety it provides by insuring that a typo in an attribute name won't silently do the wrong thing rather than attempt to assign a close-but-not-quite attribute name to an object.

More info: [Dynamic Properties in PHP](http://krisjordan.com/dynamic-properties-in-php-with-stdclass)
65 0
45 followers
Viewed: 156 290 times
Version: 1.1
Category: Tutorials
Written by: Steve Friedl
Last updated by: GOsha
Created on: Mar 31, 2011
Last updated: 6 years ago
Update Article

Revisions

View all history