<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Dynamic Properties in PHP and StdClass</title>
	<atom:link href="http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/</link>
	<description>on Software, Frameworks, &#38; Stuff</description>
	<lastBuildDate>Sat, 29 Aug 2009 05:39:48 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Rob&#8217;s Blog &#187; Blog Archive &#187; MySQLi vs PDO</title>
		<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/comment-page-1/#comment-12428</link>
		<dc:creator>Rob&#8217;s Blog &#187; Blog Archive &#187; MySQLi vs PDO</dc:creator>
		<pubDate>Tue, 21 Jul 2009 12:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.krisjordan.com/?p=451#comment-12428</guid>
		<description>[...] Kris Jordan thinks that using __get and __set is around 30 times slower than using dynamic properties on StdClass. [...]</description>
		<content:encoded><![CDATA[<p>[...] Kris Jordan thinks that using __get and __set is around 30 times slower than using dynamic properties on StdClass. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William</title>
		<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/comment-page-1/#comment-11620</link>
		<dc:creator>William</dc:creator>
		<pubDate>Fri, 10 Jul 2009 04:16:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.krisjordan.com/?p=451#comment-11620</guid>
		<description>If you want to set multiple properties on a single line, you can do:

$object = (object)array(&#039;key&#039; =&gt; &#039;value&#039;, &#039;key2&#039; =&gt; &#039;value2&#039;);

The object created will be an stdClass instance.</description>
		<content:encoded><![CDATA[<p>If you want to set multiple properties on a single line, you can do:</p>
<p>$object = (object)array(&#8217;key&#8217; =&gt; &#8216;value&#8217;, &#8216;key2&#8242; =&gt; &#8216;value2&#8242;);</p>
<p>The object created will be an stdClass instance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: m rahman</title>
		<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/comment-page-1/#comment-6967</link>
		<dc:creator>m rahman</dc:creator>
		<pubDate>Sat, 09 May 2009 05:51:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.krisjordan.com/?p=451#comment-6967</guid>
		<description>Sometimes you need declaring objects on the fly just to hold abstract members, say for packing. To use $object = new foo(); you should have declared class foo{}, while you can just object=new stdclass;</description>
		<content:encoded><![CDATA[<p>Sometimes you need declaring objects on the fly just to hold abstract members, say for packing. To use $object = new foo(); you should have declared class foo{}, while you can just object=new stdclass;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ian</title>
		<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/comment-page-1/#comment-5965</link>
		<dc:creator>ian</dc:creator>
		<pubDate>Sat, 25 Apr 2009 01:17:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.krisjordan.com/?p=451#comment-5965</guid>
		<description>had too google far &amp; wide to find your piece. any idea why this isn&#039;t documented in php.net? if it&#039;s a feature, it should be documented, but if not, it&#039;s a bug and ought to be fixed. it certainly gives the lie to the often-repeated advice to look it up in the php documentation.</description>
		<content:encoded><![CDATA[<p>had too google far &amp; wide to find your piece. any idea why this isn&#8217;t documented in php.net? if it&#8217;s a feature, it should be documented, but if not, it&#8217;s a bug and ought to be fixed. it certainly gives the lie to the often-repeated advice to look it up in the php documentation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Web development</title>
		<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/comment-page-1/#comment-1512</link>
		<dc:creator>Web development</dc:creator>
		<pubDate>Mon, 26 Jan 2009 22:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.krisjordan.com/?p=451#comment-1512</guid>
		<description>class foo {};
$object = new foo();

try above</description>
		<content:encoded><![CDATA[<p>class foo {};<br />
$object = new foo();</p>
<p>try above</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris</title>
		<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/comment-page-1/#comment-812</link>
		<dc:creator>Kris</dc:creator>
		<pubDate>Thu, 27 Nov 2008 23:15:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.krisjordan.com/?p=451#comment-812</guid>
		<description>@Duke, @Wayne - Thanks for the heads up. I&#039;ve corrected the post. Amazing the range of things PHP doesn&#039;t make obvious in the official documentation. I&#039;ve been using __get and __set in simple dynamic properties cases for years.

@Scott - StdClass is neat and nebulous. There really isn&#039;t much about it on the net. It has been claimed to be the base class for all other classes in PHP but the following code bit returns false:

&lt;code&gt;
echo $b instanceof stdclass ? &#039;yes&#039; : &#039;no&#039;; // prints &#039;no&#039;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>@Duke, @Wayne &#8211; Thanks for the heads up. I&#8217;ve corrected the post. Amazing the range of things PHP doesn&#8217;t make obvious in the official documentation. I&#8217;ve been using __get and __set in simple dynamic properties cases for years.</p>
<p>@Scott &#8211; StdClass is neat and nebulous. There really isn&#8217;t much about it on the net. It has been claimed to be the base class for all other classes in PHP but the following code bit returns false:</p>
<p><code><br />
echo $b instanceof stdclass ? 'yes' : 'no'; // prints 'no'<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: duke</title>
		<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/comment-page-1/#comment-810</link>
		<dc:creator>duke</dc:creator>
		<pubDate>Thu, 27 Nov 2008 19:35:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.krisjordan.com/?p=451#comment-810</guid>
		<description>Instead of :
class DynamicProperties extends StdClass { }  
$object = new DynamicProperties;  

You can do just:

class foo {};
$object = new foo();

and the rest of your code still works. No need to extend stdClass at all.</description>
		<content:encoded><![CDATA[<p>Instead of :<br />
class DynamicProperties extends StdClass { }<br />
$object = new DynamicProperties;  </p>
<p>You can do just:</p>
<p>class foo {};<br />
$object = new foo();</p>
<p>and the rest of your code still works. No need to extend stdClass at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/comment-page-1/#comment-809</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Thu, 27 Nov 2008 19:30:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.krisjordan.com/?p=451#comment-809</guid>
		<description>this is great, I didn&#039;t know about stdClass. Where did you find the docs? the only mention I can find on php.net is &quot;The name stdClass is used internally by Zend and is reserved. You cannot have a class named stdClass in PHP.&quot;</description>
		<content:encoded><![CDATA[<p>this is great, I didn&#8217;t know about stdClass. Where did you find the docs? the only mention I can find on php.net is &#8220;The name stdClass is used internally by Zend and is reserved. You cannot have a class named stdClass in PHP.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wayne</title>
		<link>http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/comment-page-1/#comment-808</link>
		<dc:creator>Wayne</dc:creator>
		<pubDate>Thu, 27 Nov 2008 18:26:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.krisjordan.com/?p=451#comment-808</guid>
		<description>Dynamic instance properties can be set on any class irregardless of whether or not they extend from stdClass.  Declaring properties is entirely optional in PHP and always has been.

Try your BestDynamicProperties example without extending from stdClass and you&#039;ll see that you get exactly the same result.  Now try adding properties to any other PHP class and you&#039;ll notice that works as well.  stdClass is just an empty class, it has no special abilities.

If you don&#039;t want dynamic properties on your classes (I usually don&#039;t to cut down on typos going unnoticed), you can define the __set() magic method to throw an exception.</description>
		<content:encoded><![CDATA[<p>Dynamic instance properties can be set on any class irregardless of whether or not they extend from stdClass.  Declaring properties is entirely optional in PHP and always has been.</p>
<p>Try your BestDynamicProperties example without extending from stdClass and you&#8217;ll see that you get exactly the same result.  Now try adding properties to any other PHP class and you&#8217;ll notice that works as well.  stdClass is just an empty class, it has no special abilities.</p>
<p>If you don&#8217;t want dynamic properties on your classes (I usually don&#8217;t to cut down on typos going unnoticed), you can define the __set() magic method to throw an exception.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
