<?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/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: Using PHP Generic Objects To Organize Your&#160;Code</title> <atom:link href="http://davidwalsh.name/php-generic-objects-organize-code-class/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/php-generic-objects-organize-code-class</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 19:56:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Michael Calkins</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-32210</link> <dc:creator>Michael Calkins</dc:creator> <pubDate>Wed, 16 May 2012 21:09:13 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-32210</guid> <description>Just reorganized my class however I&#039;m wonder why have a get() function and not just use $user-&gt;var[&#039;name&#039;]?</description> <content:encoded><![CDATA[<p>Just reorganized my class however I&#8217;m wonder why have a get() function and not just use $user-&gt;var['name']?</p> ]]></content:encoded> </item> <item><title>By: sherif sakr</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-30451</link> <dc:creator>sherif sakr</dc:creator> <pubDate>Sun, 26 Feb 2012 13:53:51 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-30451</guid> <description>I  have learned a lot of  useful things and enhance my my in programming   from your great blogthank you very much</description> <content:encoded><![CDATA[<p>I  have learned a lot of  useful things and enhance my my in programming   from your great blog</p><p>thank you very much</p> ]]></content:encoded> </item> <item><title>By: Marcin</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-19343</link> <dc:creator>Marcin</dc:creator> <pubDate>Thu, 12 Aug 2010 09:24:29 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-19343</guid> <description>tim, you&#039;re right ;-)
Or we can use casting:&#039;b&#039;,
&#039;c&#039; =&gt; &#039;d&#039;,
);//Make generic: ;-)
$obj = (object)$array;var_dump($obj);//unload
unset($obj-&gt;a);var_dump($obj);//set
$obj-&gt;test = &#039;foo&#039;;
var_dump($obj);//get
echo $obj-&gt;c;;-)</description> <content:encoded><![CDATA[<p>tim, you&#8217;re right ;-)<br
/> Or we can use casting:</p><p> &#8216;b&#8217;,<br
/> &#8216;c&#8217; =&gt; &#8216;d&#8217;,<br
/> );</p><p>//Make generic: ;-)<br
/> $obj = (object)$array;</p><p>var_dump($obj);</p><p>//unload<br
/> unset($obj-&gt;a);</p><p>var_dump($obj);</p><p>//set<br
/> $obj-&gt;test = &#8216;foo&#8217;;<br
/> var_dump($obj);</p><p>//get<br
/> echo $obj-&gt;c;</p><p>;-)</p> ]]></content:encoded> </item> <item><title>By: Tim</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-16260</link> <dc:creator>Tim</dc:creator> <pubDate>Thu, 25 Feb 2010 22:51:54 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-16260</guid> <description>Simplify by usingmysql_fetch_object($row, &#039;generic&#039;)This will populate all the fields of the given object using returned rows. It returns the new object.</description> <content:encoded><![CDATA[<p>Simplify by using</p><p>mysql_fetch_object($row, &#8216;generic&#8217;)</p><p>This will populate all the fields of the given object using returned rows. It returns the new object.</p> ]]></content:encoded> </item> <item><title>By: Thomas Eng</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-10204</link> <dc:creator>Thomas Eng</dc:creator> <pubDate>Tue, 07 Jul 2009 11:07:25 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-10204</guid> <description>You could alse do:function puts($s) {
print $s . &quot;\n&quot;;
}class Object {
function _&#095;construct() {
$a = array&#095;shift( func&#095;get&#095;args() );
foreach($a as $key =&gt; $value) {
$this-&gt;{$key} = $value;
}
}
}
$o = new Object(array( &quot;name&quot; =&gt; &quot;John Doe&quot;, &quot;age&quot; =&gt; 31) );
puts($o-&gt;name);
puts($o-&gt;age); </description> <content:encoded><![CDATA[<p>You could alse do:</p><p>function puts($s) {<br
/> print $s . &#8220;\n&#8221;;<br
/> }</p><p>class Object {<br
/> function _&#95;construct() {<br
/> $a = array&#95;shift( func&#95;get&#95;args() );<br
/> foreach($a as $key =&gt; $value) {<br
/> $this-&gt;{$key} = $value;<br
/> }<br
/> }<br
/> }<br
/> $o = new Object(array( &#8220;name&#8221; =&gt; &#8220;John Doe&#8221;, &#8220;age&#8221; =&gt; 31) );<br
/> puts($o-&gt;name);<br
/> puts($o-&gt;age);</p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-9964</link> <dc:creator>David Walsh</dc:creator> <pubDate>Mon, 22 Jun 2009 12:31:54 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-9964</guid> <description>&lt;p&gt;@azwan:  I don&#039;t do anything too terrible advanced with this class, although you could.  That&#039;s the beauty in its simplicity!&lt;/p&gt;</description> <content:encoded><![CDATA[<p>@azwan:  I don&#8217;t do anything too terrible advanced with this class, although you could.  That&#8217;s the beauty in its simplicity!</p> ]]></content:encoded> </item> <item><title>By: azwan</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-9959</link> <dc:creator>azwan</dc:creator> <pubDate>Mon, 22 Jun 2009 09:34:47 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-9959</guid> <description>David, thanks for sharing this. I just started learning about OOP and this class really helps. Simple and seems practical.Anyway, some questions to ask (maybe other ppl can also help)Will you use this generic class as a class for other classes to inherit/extend?
What about retrieving mulitple records (will it be array in array) in vars?I&#039;m thinking of using the class for mainly data retrieving/manipulation from database.Thanks in advance.</description> <content:encoded><![CDATA[<p>David, thanks for sharing this. I just started learning about OOP and this class really helps. Simple and seems practical.</p><p>Anyway, some questions to ask (maybe other ppl can also help)</p><p>Will you use this generic class as a class for other classes to inherit/extend?<br
/> What about retrieving mulitple records (will it be array in array) in vars?</p><p>I&#8217;m thinking of using the class for mainly data retrieving/manipulation from database.</p><p>Thanks in advance.</p> ]]></content:encoded> </item> <item><title>By: david</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-2661</link> <dc:creator>david</dc:creator> <pubDate>Fri, 08 Aug 2008 17:16:03 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-2661</guid> <description>&lt;p&gt;@Sat:  I&#039;ll fix this.  Stupid WordPress...&lt;/p&gt;</description> <content:encoded><![CDATA[<p>@Sat:  I&#8217;ll fix this.  Stupid WordPress&#8230;</p> ]]></content:encoded> </item> <item><title>By: Sat Pirott</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-2660</link> <dc:creator>Sat Pirott</dc:creator> <pubDate>Fri, 08 Aug 2008 17:01:57 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-2660</guid> <description>Hey Dave! Nice class you have there! Did not think about this option before. But anyways, there is a big &#039;error&#039; (if I can call it like that) which I like to point to. It&#039;s not in the code, rather &#039;visual&#039;. After the heading &quot;Database Usage&quot; the whole content get&#039;s bold, up to here! Dunno why, but it looks REALLY ugly! Hope you&#039;ll fix that for others :-).</description> <content:encoded><![CDATA[<p>Hey Dave! Nice class you have there! Did not think about this option before. But anyways, there is a big &#8216;error&#8217; (if I can call it like that) which I like to point to. It&#8217;s not in the code, rather &#8216;visual&#8217;. After the heading &#8220;Database Usage&#8221; the whole content get&#8217;s bold, up to here! Dunno why, but it looks REALLY ugly! Hope you&#8217;ll fix that for others :-).</p> ]]></content:encoded> </item> <item><title>By: Marc A. Champlain</title><link>http://davidwalsh.name/php-generic-objects-organize-code-class#comment-2496</link> <dc:creator>Marc A. Champlain</dc:creator> <pubDate>Wed, 30 Jul 2008 11:51:07 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-generic-objects-organize-code-class/#comment-2496</guid> <description>I code only in PHP5 so I don&#039;t know for earlier version, but you could simply do:$person = (object) null;  // or   $person = new stdClass();
$person-&gt;name = &quot;Marc&quot;;
$person-&gt;age = &quot;28&quot;;
echo $person-&gt;age; </description> <content:encoded><![CDATA[<p>I code only in PHP5 so I don&#8217;t know for earlier version, but you could simply do:</p><p>$person = (object) null;  // or   $person = new stdClass();<br
/> $person-&gt;name = &#8220;Marc&#8221;;<br
/> $person-&gt;age = &#8220;28&#8243;;<br
/> echo $person-&gt;age;</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 1/7 queries in 0.006 seconds using disk: basic
Object Caching 804/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 16:26:08 -->
