<?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>syntax of if else statement Archives - Artificial Intelligence</title>
	<atom:link href="https://www.aiuniverse.xyz/tag/syntax-of-if-else-statement/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.aiuniverse.xyz/tag/syntax-of-if-else-statement/</link>
	<description>Exploring the universe of Intelligence</description>
	<lastBuildDate>Tue, 18 Apr 2023 11:49:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>What is Conditional Statements in PHP</title>
		<link>https://www.aiuniverse.xyz/what-is-conditional-statements-in-php/</link>
					<comments>https://www.aiuniverse.xyz/what-is-conditional-statements-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Maruti Kr.]]></dc:creator>
		<pubDate>Tue, 18 Apr 2023 11:49:10 +0000</pubDate>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[how many types of conditional statements]]></category>
		<category><![CDATA[if else statement]]></category>
		<category><![CDATA[if elseif else statement]]></category>
		<category><![CDATA[if statement]]></category>
		<category><![CDATA[syntax of if else statement]]></category>
		<category><![CDATA[what is conditional statement]]></category>
		<category><![CDATA[What is Conditional Statements in PHP]]></category>
		<guid isPermaLink="false">https://www.aiuniverse.xyz/?p=16499</guid>

					<description><![CDATA[<p>In PHP, conditional statements are used to perform different actions based on different conditions. The most commonly used conditional statements in PHP are: 1. if Statement : <a class="read-more-link" href="https://www.aiuniverse.xyz/what-is-conditional-statements-in-php/">Read More</a></p>
<p>The post <a href="https://www.aiuniverse.xyz/what-is-conditional-statements-in-php/">What is Conditional Statements in PHP</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-media-text alignwide is-stacked-on-mobile"><figure class="wp-block-media-text__media"><img fetchpriority="high" decoding="async" width="1024" height="576" src="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/php-conditional-statements-2-1024x576.webp" alt="" class="wp-image-16505 size-full" srcset="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/php-conditional-statements-2-1024x576.webp 1024w, https://www.aiuniverse.xyz/wp-content/uploads/2023/04/php-conditional-statements-2-300x169.webp 300w, https://www.aiuniverse.xyz/wp-content/uploads/2023/04/php-conditional-statements-2-768x432.webp 768w, https://www.aiuniverse.xyz/wp-content/uploads/2023/04/php-conditional-statements-2.webp 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure><div class="wp-block-media-text__content">
<p>In PHP, conditional statements are used to perform different actions based on different conditions.</p>
</div></div>



<p>The most commonly used conditional statements in PHP are:</p>



<ol class="wp-block-list">
<li>if Statement.</li>



<li>if-else Statement</li>



<li>If-elseif-else Statement</li>



<li>Switch statement</li>
</ol>



<p><strong>1. if Statement</strong> : If statement is used to test a condition and execute a block of code if the condition is true.</p>



<p><strong>Syntax:</strong></p>



<pre class="wp-block-code"><code>if(condition)
{  
//code to be executed  
}  </code></pre>



<p><strong>Flowchart</strong>:</p>



<figure class="wp-block-image size-full"><img decoding="async" width="344" height="513" src="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/1-6.png" alt="" class="wp-image-16500" srcset="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/1-6.png 344w, https://www.aiuniverse.xyz/wp-content/uploads/2023/04/1-6-201x300.png 201w" sizes="(max-width: 344px) 100vw, 344px" /></figure>



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



<pre class="wp-block-code"><code>$num = 20;

if ($num > 5) 
{
   echo "The number is greater than 5.";
}
</code></pre>



<p><strong>2. if-else Statement</strong>: This statement is used to check a condition and execute one block of code if the condition is true and another block of code if the condition is false.</p>



<p><strong>syntax:</strong></p>



<pre class="wp-block-code"><code>if(condition)
{  
//code to be executed if true  
}
else
{  
//code to be executed if false  
}  </code></pre>



<p><strong>Flowchart</strong>:</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/22-3.png" alt="" class="wp-image-16501" width="387" height="514" srcset="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/22-3.png 387w, https://www.aiuniverse.xyz/wp-content/uploads/2023/04/22-3-226x300.png 226w" sizes="(max-width: 387px) 100vw, 387px" /></figure>



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



<pre class="wp-block-code"><code>$num = 5;

if ($num > 10) 
{
   echo "The number is greater than 10.";
} 
else 
{
   echo "The number is less than or equal to 5.";
}
</code></pre>



<p><strong>3. If-else-if-else:</strong> This statement is used to Check multiple conditions and execute different blocks of code based on those conditions.</p>



<p><strong>Syntax:</strong> </p>



<pre class="wp-block-code"><code>if (condition1)
{    
//code to be executed if condition1 is true    
} elseif (condition2)
{      
//code to be executed if condition2 is true    
} elseif (condition3)
{      
//code to be executed if condition3 is true    
...
}  else
{    
//code to be executed if all given conditions are false    
}    </code></pre>



<p><strong>Flowchart</strong>:</p>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="604" height="447" src="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/3-8.png" alt="" class="wp-image-16502" srcset="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/3-8.png 604w, https://www.aiuniverse.xyz/wp-content/uploads/2023/04/3-8-300x222.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /></figure>



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



<pre class="wp-block-code"><code>$num = 7;

if ($num > 10) 
{
   echo "The number is greater than 10.";
}
else if ($num > 5) 
{
   echo "The number is greater than 5 but less than or equal to 10.";
} 
else 
{
   echo "The number is less than or equal to 5.";
}
</code></pre>



<p><strong>4. Switch Statement:</strong> </p>



<p>PHP switch statement is used to execute one statement from multiple conditions. It works like PHP if-else-if statement.</p>



<p><strong>Syntax:</strong></p>



<pre class="wp-block-code"><code>switch(expression)
{      
case value1:      
 //code to be executed  
 break;  
case value2:      
 //code to be executed  
 break;  
......      
default:       
 code to be executed if all cases are not matched;    
}  </code></pre>



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



<pre class="wp-block-code"><code><div tabindex="0">&lt;?php$i = "2";switch ($i) {    case 0:        echo "i equals 0";        break;    case 1:        echo "i equals 1";        break;    case 2:        echo "i equals 2";        break;    default:       echo "i is not equal to 0, 1 or 2";}?></div></code></pre>
<p>The post <a href="https://www.aiuniverse.xyz/what-is-conditional-statements-in-php/">What is Conditional Statements 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-conditional-statements-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
