<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1043067" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1043067</link>
    <description></description>
    <language>en</language>
          <item>
    <title>EDIT: decibel beat me to it</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/arg-function#comment-1238328</link>
    <description> &lt;p&gt;EDIT: decibel beat me to it &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/grin.png&quot; title=&quot;Laugh&quot; alt=&quot;Laugh&quot; class=&quot;smiley-content&quot; /&gt; (although I mentioned not using a function at all, which is fine (better) in most cases)&lt;/p&gt;
&lt;p&gt;I don&#039;t have a fantastic knowledge with functions, so perhaps someone else will explain why some of that code is &quot;required&quot;, but to me it appears to be extremely bloated.&lt;/p&gt;
&lt;p&gt;To double a number, wouldn&#039;t this be better:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;double_number&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$num&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$num &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$num &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;* &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$num&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;double_number&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Or instead of echoing you can add the value to a var&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$doubled_number &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;double_number&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Then echo it in whatever text you want&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;My new number now doubled is &quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$doubled_number&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;But to be honest, I don&#039;t see the point in ever using a function for something so simple &lt;strong&gt;unless you use it many times&lt;/strong&gt;, which is the point of a function.&lt;/p&gt;
&lt;p&gt;Simply having this would suffice in &quot;most&quot; cases and is much less use of resource for the server:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;My new number is &quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;; echo &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;12 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;* &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The only time you would really use the above in a function is if you are doubling many numbers throughout your page/script/site, and even then only if there were other calculations, such as &lt;a href=&quot;http://uk3.php.net/round&quot;&gt;Round&lt;/a&gt;, &lt;a href=&quot;http://uk3.php.net/manual/en/function.ceil.php&quot;&gt;Ceil&lt;/a&gt; or &lt;a href=&quot;http://uk3.php.net/manual/en/function.floor.php&quot;&gt;Floor&lt;/a&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 16 Feb 2009 16:50:00 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1238328 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Thank you for all your help.</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/arg-function#comment-1238327</link>
    <description> &lt;p&gt;Thank you for all your help. I agree with your method, it make more sence and it is much more practical.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
 </description>
     <pubDate>Mon, 16 Feb 2009 16:36:48 +0000</pubDate>
 <dc:creator>busman</dc:creator>
 <guid isPermaLink="false">comment 1238327 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>hi busman,
the code calls</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/arg-function#comment-1238324</link>
    <description> &lt;p&gt;hi busman,&lt;/p&gt;
&lt;p&gt;the code calls the show_number() function and passes the value 12 to it&lt;/p&gt;
&lt;p&gt;&lt;code&gt;show_number(12);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;the function assigns the passed value 12 to the variable $num&lt;/p&gt;
&lt;p&gt;&lt;code&gt;function show_number($num)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;then it passes the value of $num which is 12 to the function make_double() and assigns the returned value (24) to a variable $new_number&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$new_number = make_double($num);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;the make_double() function adds $arg + $arg to double its value - the value of $arg is the value of $num which is 12 - and returns the sum (24) to the show_number() function as the value of $new_number&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;function make_double($arg){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return $arg + $arg;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;function show_number() continues by echoing (or writing) the text plus the value of $newnumber that was returned by function make_double() - ie 24&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;echo( &amp;quot;The value is $new_number&amp;quot; );&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;however, I would remove the parentheses from the echo statement:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;echo &amp;quot;The value is $new_number&amp;quot;;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;on the page you should see&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;The value is 24&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I would rewrite the show_number() function - the make_double() function is unnecessary:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;show_number&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$num&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$new_number &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$num &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$num&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;The value is &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$new_number&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 16 Feb 2009 16:22:52 +0000</pubDate>
 <dc:creator>decibel.places</dc:creator>
 <guid isPermaLink="false">comment 1238324 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
