<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>What is Function Arguments in PHP ? Archives - Artificial Intelligence</title>
	<atom:link href="https://www.aiuniverse.xyz/tag/what-is-function-arguments-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.aiuniverse.xyz/tag/what-is-function-arguments-in-php/</link>
	<description>Exploring the universe of Intelligence</description>
	<lastBuildDate>Thu, 27 Apr 2023 11:00:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>What is Function Arguments in PHP ?</title>
		<link>https://www.aiuniverse.xyz/what-is-function-arguments-in-php/</link>
					<comments>https://www.aiuniverse.xyz/what-is-function-arguments-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Maruti Kr.]]></dc:creator>
		<pubDate>Thu, 27 Apr 2023 11:00:42 +0000</pubDate>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Call by Reference]]></category>
		<category><![CDATA[Call by Value]]></category>
		<category><![CDATA[Default Argument Values]]></category>
		<category><![CDATA[Variable Length Argument]]></category>
		<category><![CDATA[What is Function Arguments in PHP ?]]></category>
		<guid isPermaLink="false">https://www.aiuniverse.xyz/?p=16591</guid>

					<description><![CDATA[<p>PHP function argument refers to a value that is passed into a function when it is called. PHP Arguments supports Call by Value, Call by Reference, Default Argument Values and Variable-length argument. 1. Call by Value: In Call by Value, the value of a variable is passed directly. This means if the value of a <a class="read-more-link" href="https://www.aiuniverse.xyz/what-is-function-arguments-in-php/">Read More</a></p>
<p>The post <a href="https://www.aiuniverse.xyz/what-is-function-arguments-in-php/">What is Function Arguments in PHP ?</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>PHP function argument refers to a value that is passed into a function when it is called. PHP Arguments supports Call by Value, Call by Reference, Default Argument Values and Variable-length argument.</p>



<h2 class="wp-block-heading">1. Call by Value:</h2>



<p>In Call by Value, the value of a variable is passed directly. This means if the value of a variable within the function is changed, it does not get changed outside of the function. </p>



<p><strong>Example:</strong></p>



<pre class="wp-block-code"><code>&lt;?php  
function increment($i)  
{  
    $i++;  
}  
$i = 10;  
increment($i);  
echo $i;  
?>  </code></pre>



<p><strong>Output:</strong> </p>



<pre class="wp-block-code"><code>10</code></pre>



<h2 class="wp-block-heading">2. Call by Reference:</h2>



<p>In PHP, call by reference is a mechanism in which a function can directly modify the original value of a variable outside of the function. By default, function arguments are passed by value in PHP, which means that a copy of the argument&#8217;s value is passed to the function. However, you can pass arguments by reference using the <code>&amp;</code> symbol to allow the function to modify the original value of the variable.</p>



<p><strong>Example:</strong></p>



<pre class="wp-block-code"><code>&lt;?php  
function increment(&amp;$i)  
{  
    $i++;  
}  
$i = 10;  
increment($i);  
echo $i;  
?> </code></pre>



<p><strong>Output:</strong> </p>



<pre class="wp-block-code"><code>11</code></pre>



<h2 class="wp-block-heading">3. Default Argument Values:</h2>



<p>When you calling PHP function if you don&#8217;t specify any argument, it will take the default argument.</p>



<p><strong>Example:</strong></p>



<pre class="wp-block-code"><code>&lt;?php  
function Hello($name="Amit"){  
echo "Hello $name &lt;br>";  
}  
Hello("Abishek");  
Hello();//passing no value  
Hello("Vijay");  
?>  </code></pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-code"><code>Hello Amit
Hello Abhishek
Hello Vijay</code></pre>



<h2 class="wp-block-heading">4. Variable Length Argument:</h2>



<p>It is used when we need to pass n number of arguments in a function. To use this, we need to write three dots inside the parenthesis before the argument. </p>



<p><strong>Example:</strong></p>



<pre class="wp-block-code"><code>&lt;?php  
function add(...$nums) {  
    $sum = 0;  
    foreach ($nums as $n) {  
        $sum += $n;  
    }  
    return $sum;  
} 
echo add(2, 4, 6, 8);  
?>  </code></pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-code"><code>20</code></pre>
<p>The post <a href="https://www.aiuniverse.xyz/what-is-function-arguments-in-php/">What is Function Arguments in PHP ?</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.aiuniverse.xyz/what-is-function-arguments-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
