<?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: Create PHP Classes with Dynamic&#160;Functions</title> <atom:link href="http://davidwalsh.name/dynamic-functions/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/dynamic-functions</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Thu, 09 Feb 2012 07:54:33 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>By: kailash malav</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-24247</link> <dc:creator>kailash malav</dc:creator> <pubDate>Fri, 27 May 2011 11:25:41 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-24247</guid> <description>Good for beginners..............</description> <content:encoded><![CDATA[<p>Good for beginners&#8230;&#8230;&#8230;&#8230;..</p> ]]></content:encoded> </item> <item><title>By: Rwk</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-21119</link> <dc:creator>Rwk</dc:creator> <pubDate>Wed, 27 Oct 2010 00:29:42 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-21119</guid> <description>Nice tips !I followed the links in comments and it is real one revelations.I am great satisfied, thank you =)</description> <content:encoded><![CDATA[<p>Nice tips !</p><p>I followed the links in comments and it is real one revelations.</p><p>I am great satisfied, thank you =)</p> ]]></content:encoded> </item> <item><title>By: PPafford</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-20840</link> <dc:creator>PPafford</dc:creator> <pubDate>Wed, 29 Sep 2010 18:45:46 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-20840</guid> <description>&lt;code&gt;
/**
* This class creates a dynamic shell to
* define and set any Setter or Getter
*
* Example:
*
* $property = new DynamicPropertiesUtility();
* $property-&gt;setFax(&quot;123-123-1234&quot;); // set[anything here first letter upper case](&quot;value here&quot;)
* echo $property-&gt;getFax().&quot;\n&quot;; // get[anything here first letter upper case]()
*/class DynamicPropertiesUtility {
private $properties;
public function __call($name, $args) {
if (preg_match(&#039;!(get&#124;set)(\w+)!&#039;, $name, $match)) {
$prop = $match[2];
if ($match[1] == &#039;get&#039;) {
if (count($args) != 0) {
throw new Exception(&quot;Method &#039;$name&#039; expected 0 arguments, got &quot; . count($args).&quot;\n&quot;);
}
return $this-&gt;properties[$prop];
} else {
if (count($args) != 1) {
throw new Exception(&quot;Method &#039;$name&#039; expected 1 argument, got &quot; . count($args).&quot;\n&quot;);
}
$this-&gt;properties[$prop] = $args[0];
}
} else {
throw new Exception(&quot;Unknown method $name&quot;);
}
}
}
&lt;/code&gt;</description> <content:encoded><![CDATA[<p><code><br
/> /**<br
/> * This class creates a dynamic shell to<br
/> * define and set any Setter or Getter<br
/> *<br
/> * Example:<br
/> *<br
/> * $property = new DynamicPropertiesUtility();<br
/> * $property-&gt;setFax("123-123-1234"); // set[anything here first letter upper case]("value here")<br
/> * echo $property-&gt;getFax()."\n"; // get[anything here first letter upper case]()<br
/> */</p><p>class DynamicPropertiesUtility {<br
/> private $properties;</p><p> public function __call($name, $args) {<br
/> if (preg_match('!(get|set)(\w+)!', $name, $match)) {<br
/> $prop = $match[2];<br
/> if ($match[1] == 'get') {<br
/> if (count($args) != 0) {<br
/> throw new Exception("Method '$name' expected 0 arguments, got " . count($args)."\n");<br
/> }<br
/> return $this-&gt;properties[$prop];<br
/> } else {<br
/> if (count($args) != 1) {<br
/> throw new Exception("Method '$name' expected 1 argument, got " . count($args)."\n");<br
/> }<br
/> $this-&gt;properties[$prop] = $args[0];<br
/> }<br
/> } else {<br
/> throw new Exception("Unknown method $name");<br
/> }<br
/> }<br
/> }<br
/> </code></p> ]]></content:encoded> </item> <item><title>By: Tibor Szász</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-14381</link> <dc:creator>Tibor Szász</dc:creator> <pubDate>Wed, 09 Dec 2009 21:09:34 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-14381</guid> <description>Very useful, thanks for the advice</description> <content:encoded><![CDATA[<p>Very useful, thanks for the advice</p> ]]></content:encoded> </item> <item><title>By: ilaçlama</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-14296</link> <dc:creator>ilaçlama</dc:creator> <pubDate>Tue, 08 Dec 2009 09:31:41 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-14296</guid> <description>$record = array(
&#039;id&#039; =&gt; 12,
&#039;title&#039; =&gt; &#039;title&#039;,
&#039;description&#039; =&gt; &#039;description&#039;
);
php is frameworks...</description> <content:encoded><![CDATA[<p>$record = array(<br
/> &#8216;id&#8217; =&gt; 12,<br
/> &#8216;title&#8217; =&gt; &#8216;title&#8217;,<br
/> &#8216;description&#8217; =&gt; &#8216;description&#8217;<br
/> );<br
/> php is frameworks&#8230;</p> ]]></content:encoded> </item> <item><title>By: Arian</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-14269</link> <dc:creator>Arian</dc:creator> <pubDate>Mon, 07 Dec 2009 21:54:15 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-14269</guid> <description>Why do you use the PHP4 class syntax (no public/private/protected, no __construct)besides, it is faster to use a set() and get() method. php will look first at all methods of your class if the method exists and then call __call(), so it&#039;s slower than just set()/get()</description> <content:encoded><![CDATA[<p>Why do you use the PHP4 class syntax (no public/private/protected, no __construct)</p><p>besides, it is faster to use a set() and get() method. php will look first at all methods of your class if the method exists and then call __call(), so it&#8217;s slower than just set()/get()</p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-14232</link> <dc:creator>David Walsh</dc:creator> <pubDate>Sat, 05 Dec 2009 20:06:56 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-14232</guid> <description>@Robin:  Thank you for the link -- makes sense and provides great detail.</description> <content:encoded><![CDATA[<p>@Robin:  Thank you for the link &#8212; makes sense and provides great detail.</p> ]]></content:encoded> </item> <item><title>By: Robin</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-14230</link> <dc:creator>Robin</dc:creator> <pubDate>Sat, 05 Dec 2009 19:50:19 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-14230</guid> <description>Here is another tutorial which explains the same, but more complete and a better implementation (almost 4 years old already):
http://www.ibm.com/developerworks/xml/library/os-php-flexobj/</description> <content:encoded><![CDATA[<p>Here is another tutorial which explains the same, but more complete and a better implementation (almost 4 years old already):<br
/> <a
href="http://www.ibm.com/developerworks/xml/library/os-php-flexobj/" rel="nofollow">http://www.ibm.com/developerworks/xml/library/os-php-flexobj/</a></p> ]]></content:encoded> </item> <item><title>By: deef</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-14228</link> <dc:creator>deef</dc:creator> <pubDate>Sat, 05 Dec 2009 14:31:15 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-14228</guid> <description>I came across a nice intro on this subject at http://www.killerphp.com/articles/getting-into-php6-and-advanced-php-concepts-part-4/</description> <content:encoded><![CDATA[<p>I came across a nice intro on this subject at <a
href="http://www.killerphp.com/articles/getting-into-php6-and-advanced-php-concepts-part-4/" rel="nofollow">http://www.killerphp.com/articles/getting-into-php6-and-advanced-php-concepts-part-4/</a></p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/dynamic-functions/comment-page-1#comment-14222</link> <dc:creator>David Walsh</dc:creator> <pubDate>Fri, 04 Dec 2009 23:01:08 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4323#comment-14222</guid> <description>Yeah, I hate prefixing variables with underscore.</description> <content:encoded><![CDATA[<p>Yeah, I hate prefixing variables with underscore.</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/17 queries in 0.022 seconds using disk: basic
Object Caching 865/866 objects using disk: basic

Served from: davidwalsh.name @ 2012-02-09 03:49:19 -->
