<?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: parameters with default values</title>
	<atom:link href="http://br.bingorabbit.com/2008/06/parameters_with_default_values/feed/" rel="self" type="application/rss+xml" />
	<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/</link>
	<description></description>
	<lastBuildDate>Tue, 07 Sep 2010 07:12:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: kamasheto</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1560</link>
		<dc:creator>kamasheto</dc:creator>
		<pubDate>Sun, 15 Jun 2008 16:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1560</guid>
		<description>Gah.

I understand there are two problems, but when thinking in a programmable way to solve a problem I only think of solving what I can see.. mesh hanagem masalan trying to figure out any other problem that might have existed.

Nevertheless, this implementation could easily be hacked to make sure more than 2 arguments get through to your nameAndAge method. If one can&#039;t see that straight away, one shouldn&#039;t be attempting the first place.</description>
		<content:encoded><![CDATA[<p>Gah.</p>
<p>I understand there are two problems, but when thinking in a programmable way to solve a problem I only think of solving what I can see.. mesh hanagem masalan trying to figure out any other problem that might have existed.</p>
<p>Nevertheless, this implementation could easily be hacked to make sure more than 2 arguments get through to your nameAndAge method. If one can&#8217;t see that straight away, one shouldn&#8217;t be attempting the first place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bingorabbit</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1558</link>
		<dc:creator>bingorabbit</dc:creator>
		<pubDate>Sun, 15 Jun 2008 16:06:37 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1558</guid>
		<description>la2 ya kama, dah 7aga kanet fel course, dah bas misunderstanding between both of you, I know what both of you mean :D</description>
		<content:encoded><![CDATA[<p>la2 ya kama, dah 7aga kanet fel course, dah bas misunderstanding between both of you, I know what both of you mean <img src='http://br.bingorabbit.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kamasheto</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1557</link>
		<dc:creator>kamasheto</dc:creator>
		<pubDate>Sun, 15 Jun 2008 16:03:24 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1557</guid>
		<description>Then I suggest you read bingo&#039;s post again.</description>
		<content:encoded><![CDATA[<p>Then I suggest you read bingo&#8217;s post again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osama_gma</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1556</link>
		<dc:creator>osama_gma</dc:creator>
		<pubDate>Sun, 15 Jun 2008 16:01:17 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1556</guid>
		<description>aywa we el Original problem heya en ana kont bas2al BinGo law ana 3ayz ad5al value le el Second parameter aw third men 3&#039;eer mada5al le el first we el second..</description>
		<content:encoded><![CDATA[<p>aywa we el Original problem heya en ana kont bas2al BinGo law ana 3ayz ad5al value le el Second parameter aw third men 3&#8242;eer mada5al le el first we el second..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kamasheto</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1555</link>
		<dc:creator>kamasheto</dc:creator>
		<pubDate>Sun, 15 Jun 2008 15:53:20 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1555</guid>
		<description>@Osama: 

It&#039;s always a good idea to have the original problem in mind when working on a solution, it helps not getting carried away with your imagination.

Regards.</description>
		<content:encoded><![CDATA[<p>@Osama: </p>
<p>It&#8217;s always a good idea to have the original problem in mind when working on a solution, it helps not getting carried away with your imagination.</p>
<p>Regards.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osama_gma</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1549</link>
		<dc:creator>osama_gma</dc:creator>
		<pubDate>Sun, 15 Jun 2008 14:12:05 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1549</guid>
		<description>Thanks Bingo for your interest.

&lt;b&gt;@Kama:&lt;/b&gt;
EL Code beta3k howa Solution le el Problem beta3t el &quot;age, name&quot; parameters bas
Consider mathlan paramters zay &quot;address, name&quot; or &quot;mobile, phone&quot;
So el code beta3k howa special case

Regards,</description>
		<content:encoded><![CDATA[<p>Thanks Bingo for your interest.</p>
<p><b>@Kama:</b><br />
EL Code beta3k howa Solution le el Problem beta3t el &#8220;age, name&#8221; parameters bas<br />
Consider mathlan paramters zay &#8220;address, name&#8221; or &#8220;mobile, phone&#8221;<br />
So el code beta3k howa special case</p>
<p>Regards,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bingorabbit</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1394</link>
		<dc:creator>bingorabbit</dc:creator>
		<pubDate>Fri, 13 Jun 2008 00:27:08 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1394</guid>
		<description>@kamasheto: I thought of the same script with exactly the same implementation, but I just mentioned the simple implementation not the &quot;long&quot; one :D , anyway glad u like it and thanks for the last comment, really this completes the post :)</description>
		<content:encoded><![CDATA[<p>@kamasheto: I thought of the same script with exactly the same implementation, but I just mentioned the simple implementation not the &#8220;long&#8221; one <img src='http://br.bingorabbit.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> , anyway glad u like it and thanks for the last comment, really this completes the post <img src='http://br.bingorabbit.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kamasheto</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1373</link>
		<dc:creator>kamasheto</dc:creator>
		<pubDate>Thu, 12 Jun 2008 11:14:45 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1373</guid>
		<description>Okay, now the technical post.

If you were going to use nameAndAge() with empty arguments you didn&#039;t need to use those new functions. I don&#039;t really think this implementation solves the previously encountered problem(s), you still have to give the arguments in the order they are expected.

This would have worked just as good:

&lt;code&gt;&lt;pre&gt;&lt;?php
	function nameAndAge($name, $age){
		if(!$name) $name = &#039;bingorabbit&#039;;
		if(!$age) $age = 15;
		echo &#039;Welcome &#039; . $name . &#039;, you are &#039; . $age . &#039; years old.&#039;;
	}
	nameAndAge(&#039;&#039;,20); // prints Welcome bingorabbit, you are 20 years old.
	nameAndAge(&#039;ahmed&#039;,&#039;&#039;); // prints Welcome ahmed, you are 15 years old.
?&gt;&lt;/pre&gt;&lt;/code&gt;

A much better usage of those functions would be as follows:

&lt;code&gt;&lt;pre&gt;&lt;?php
	function nameAndAge(){
		$name = &#039;bingorabbit&#039;;
		$age = 15;
		$argsLength = func_num_args();
		$args = func_get_args();
		if( $argsLength == 1 ) {
			if( $args[0] ) {
				if( (int)$args[0] &gt; 0 ) {
					$age = (int)$args[0];
				} else {
					$name = $args[0];
				}
			}
		} else if( $argsLength == 2 ) {
			if( $args[0] ) {
				if( (int)$args[0] &gt; 0 ) {
					$age = (int)$args[0];
				} else {
					$name = $args[0];
				}
			}
			if( $args[1] ) {
				if( (int)$args[1] &gt; 0 ) {
					$age = (int)$args[1];
				} else {
					$name = $args[1];
				}
			}			
		}
		echo &#039;Welcome &#039; . $name . &#039;, you are &#039; . $age . &#039; years old.&#039;;
	}
	nameAndAge(20); // prints Welcome bingorabbit, you are 20 years old.
	nameAndAge(&#039;ahmed&#039;); // prints Welcome ahmed, you are 15 years old.
?&gt;&lt;/pre&gt;&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Okay, now the technical post.</p>
<p>If you were going to use nameAndAge() with empty arguments you didn&#8217;t need to use those new functions. I don&#8217;t really think this implementation solves the previously encountered problem(s), you still have to give the arguments in the order they are expected.</p>
<p>This would have worked just as good:</p>
<p><code>
<pre>< ?php
	function nameAndAge($name, $age){
		if(!$name) $name = 'bingorabbit';
		if(!$age) $age = 15;
		echo 'Welcome ' . $name . ', you are ' . $age . ' years old.';
	}
	nameAndAge('',20); // prints Welcome bingorabbit, you are 20 years old.
	nameAndAge('ahmed',''); // prints Welcome ahmed, you are 15 years old.
?></pre>
<p></code></p>
<p>A much better usage of those functions would be as follows:</p>
<p><code>
<pre>< ?php
	function nameAndAge(){
		$name = 'bingorabbit';
		$age = 15;
		$argsLength = func_num_args();
		$args = func_get_args();
		if( $argsLength == 1 ) {
			if( $args[0] ) {
				if( (int)$args[0] > 0 ) {
					$age = (int)$args[0];
				} else {
					$name = $args[0];
				}
			}
		} else if( $argsLength == 2 ) {
			if( $args[0] ) {
				if( (int)$args[0] > 0 ) {
					$age = (int)$args[0];
				} else {
					$name = $args[0];
				}
			}
			if( $args[1] ) {
				if( (int)$args[1] > 0 ) {
					$age = (int)$args[1];
				} else {
					$name = $args[1];
				}
			}
		}
		echo 'Welcome ' . $name . ', you are ' . $age . ' years old.';
	}
	nameAndAge(20); // prints Welcome bingorabbit, you are 20 years old.
	nameAndAge('ahmed'); // prints Welcome ahmed, you are 15 years old.
?></pre>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kamasheto</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1329</link>
		<dc:creator>kamasheto</dc:creator>
		<pubDate>Wed, 11 Jun 2008 18:47:44 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1329</guid>
		<description>Apparently there are a number of functions that deal with functions.

A list could be found &lt;a href=&quot;http://www.php.net/manual/en/ref.funchand.php&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Apparently there are a number of functions that deal with functions.</p>
<p>A list could be found <a href="http://www.php.net/manual/en/ref.funchand.php" rel="nofollow">here</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kamasheto</title>
		<link>http://br.bingorabbit.com/2008/06/parameters_with_default_values/comment-page-1/#comment-1327</link>
		<dc:creator>kamasheto</dc:creator>
		<pubDate>Wed, 11 Jun 2008 18:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://br.bingorabbit.com/?p=154#comment-1327</guid>
		<description>URGHHGHHH!!

I have two thoughts on mind right now. One, this totally rocks! PHP has become extremely flexible that I don&#039;t even need to bother considering how many parameters I need to deal with.. and the second thought, this TOTALLY SUCKS! PHP has become extremely flexible just reading about it gives you the sense of flawlessness!

We all know what people do with JavaScript and how easily it could be hacked into. Who wants a more dangerous programming language that could potentially damage the users.

GAH!

Thanks though for sharing =) It&#039;s the first new thing I&#039;ve learnt in quite some time..</description>
		<content:encoded><![CDATA[<p>URGHHGHHH!!</p>
<p>I have two thoughts on mind right now. One, this totally rocks! PHP has become extremely flexible that I don&#8217;t even need to bother considering how many parameters I need to deal with.. and the second thought, this TOTALLY SUCKS! PHP has become extremely flexible just reading about it gives you the sense of flawlessness!</p>
<p>We all know what people do with JavaScript and how easily it could be hacked into. Who wants a more dangerous programming language that could potentially damage the users.</p>
<p>GAH!</p>
<p>Thanks though for sharing =) It&#8217;s the first new thing I&#8217;ve learnt in quite some time..</p>
]]></content:encoded>
	</item>
</channel>
</rss>
