<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Perplexed Labs - Latest Comments in PHP Named Parameters</title><link>http://plabs.disqus.com/</link><description>web development war stories from the frontlines to the backend</description><atom:link href="https://plabs.disqus.com/php_named_parameters/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 07 Jan 2010 20:26:09 -0000</lastBuildDate><item><title>Re: PHP Named Parameters</title><link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/#comment-28849094</link><description>&lt;p&gt;This is similar to what we've done, but we used different elbow-grease.  See --&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.seoegghead.com/software/downloads/php-parameter-skipping-and-named-parameters.php" rel="nofollow noopener" target="_blank" title="http://www.seoegghead.com/software/downloads/php-parameter-skipping-and-named-parameters.php"&gt;http://www.seoegghead.com/s...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;We hijack the parameter list via an include.  It's a hack, but it's elegant, and it's always the same cut-and-pasted include.  The overhead is minimal, and zero string parsing needed.&lt;/p&gt;&lt;p&gt;Then we can do this:&lt;/p&gt;&lt;p&gt;getUsers(_, _, $username);&lt;/p&gt;&lt;p&gt;-or-&lt;/p&gt;&lt;p&gt;getUsers(PAR('username', $username));&lt;/p&gt;&lt;p&gt;I think our implementation is a little more correct (at the expense of being a little more annoying), but there is definitely some parallel thinking here.&lt;/p&gt;&lt;p&gt;I wish people like @hylje would stop being snarky.  The world would be a better place.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jaimie Sirovich</dc:creator><pubDate>Thu, 07 Jan 2010 20:26:09 -0000</pubDate></item><item><title>Re: PHP Named Parameters</title><link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/#comment-9024141</link><description>&lt;p&gt;The array solution makes code more difficult to read - this is more succint.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt</dc:creator><pubDate>Sat, 02 May 2009 22:33:17 -0000</pubDate></item><item><title>Re: PHP Named Parameters</title><link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/#comment-9024140</link><description>&lt;p&gt;Why wouldn't array solution just fit your needs ? just because you have to type in "array" construct ?&lt;/p&gt;&lt;p&gt;This is not python, it is PHP, get used to it having his own ways(most of them bad ways)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">iongion</dc:creator><pubDate>Sat, 02 May 2009 19:57:54 -0000</pubDate></item><item><title>Re: PHP Named Parameters</title><link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/#comment-9024139</link><description>&lt;p&gt;@david&lt;/p&gt;&lt;p&gt;Because PHP doesn't natively support true named parameter passing this is mostly a "hack".&lt;/p&gt;&lt;p&gt;Also, because PHP is loosely typed and you can't specify that a certain method parameter only accept an Object, I can't think of any way to handle that special case.&lt;/p&gt;&lt;p&gt;I wouldn't suggest this solution be adopted for general programming in PHP however there are some specific cases where this can be very useful.  One of them would be in the creation of Rails like helper methods for a view (which is where I'm using it now in my own projects).&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt</dc:creator><pubDate>Wed, 22 Apr 2009 17:43:16 -0000</pubDate></item><item><title>Re: PHP Named Parameters</title><link>http://blog.perplexedlabs.com/2009/04/22/php-named-parameters/#comment-9024138</link><description>&lt;p&gt;in the switch at line 64 -- how do I pass in parameters whose type are Object? It appears to be only testing for simple types (strings, bools, numbers ...) which are known.&lt;/p&gt;&lt;p&gt;how is this clearer than just making every function in your object have a signature such as:&lt;/p&gt;&lt;p&gt;function foo($opts=array()) { return $blah; }&lt;/p&gt;&lt;p&gt;yes, you get some default named parameter value handling from some boilerplate code ... but it appears you're limiting what kinds of parameters you are able to pass around ... imho this looks like over-engineering that'll lead to coding yourself into a corner.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">david g.</dc:creator><pubDate>Wed, 22 Apr 2009 17:35:06 -0000</pubDate></item></channel></rss>