<?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>Web Design company - Goweb99 blog &#187; switch statement</title>
	<atom:link href="http://www.goweb99.com/blog/tag/switch-statement/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.goweb99.com/blog</link>
	<description>Get your website designed for as low as $99.</description>
	<lastBuildDate>Fri, 30 Jul 2010 20:27:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Switch Statement</title>
		<link>http://www.goweb99.com/blog/php-tutorial/php-switch-statement/</link>
		<comments>http://www.goweb99.com/blog/php-tutorial/php-switch-statement/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 11:01:25 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[php switch]]></category>
		<category><![CDATA[php switch case]]></category>
		<category><![CDATA[switch case]]></category>
		<category><![CDATA[switch statement]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=454</guid>
		<description><![CDATA[We have seen that If…elseif…else statement can be used where there are multiple conditions, but if the conditions are 20 or 30, then this number of if and elseif will look very clumsy. This may even decrease the code readability.
The other way round to solve this problem is to use the switch statement. As the [...]]]></description>
			<content:encoded><![CDATA[<p>We have seen that If…elseif…else statement can be used where there are multiple conditions, but if the conditions are 20 or 30, then this number of if and elseif will look very clumsy. This may even decrease the code readability.</p>
<p>The other way round to solve this problem is to use the switch statement. As the name implies, it is a switch kind of construct, which switches between which code to execute, depending upon the value of switch variable.</p>
<p>Switch statement takes a single variable as input and then checks it against all the different cases you set up for that switch statement.</p>
<p><strong>The PHP Switch Statement<br />
</strong><br />
Use the switch statement to select one of many blocks of code to be executed.</p>
<p>Syntax</p>
<ul> switch (n)<br />
{<br />
case label1:<br />
code to be executed if n=label1;<br />
break;<br />
case label2:<br />
code to be executed if n=label2;<br />
break;<br />
default:<br />
code to be executed if n is different from both label1 and label2;<br />
}</ul>
<p>First we have a single expression or a variable n, which is evaluated once. The value of the expression is then compared with the values for each case in the structure. If the expression value matches with a case value, the block of code associated with that case is executed.</p>
<p>At the end of each code block of every case ther is break statement, this break statement says that the condition is fulfilled so break out of the switch case. This prevents the code from running into the next case automatically.</p>
<p>After all the cases have been defined, we define a default case. This default case, as its name implies, is a case which is executed if the expression value matches with no other case value.</p>
<p>You can print a generic statement saying wrong choice or no matching values so that the user may know that a wrong input is given.</p>
<ul>
<div class="example">For eg:</p>
<p>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;?php<br />
switch ($x)<br />
{<br />
case 1:<br />
echo &#8220;Number 1&#8243;;<br />
break;<br />
case 2:<br />
echo &#8220;Number 2&#8243;;<br />
break;<br />
case 3:<br />
echo &#8220;Number 3&#8243;;<br />
break;<br />
default:<br />
echo &#8220;No number between 1 and 3&#8243;;<br />
}<br />
?&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></div>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/php-tutorial/php-switch-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conditional Statements</title>
		<link>http://www.goweb99.com/blog/php-tutorial/conditional-statements/</link>
		<comments>http://www.goweb99.com/blog/php-tutorial/conditional-statements/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 10:08:36 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[if statement]]></category>
		<category><![CDATA[if...else]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php if-else]]></category>
		<category><![CDATA[php switch]]></category>
		<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[PHP Tuts]]></category>
		<category><![CDATA[switch case]]></category>
		<category><![CDATA[switch statement]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=440</guid>
		<description><![CDATA[Conditional statements are used to evaluate some conditions and perform different actions based on the outcome.
You can use conditional statements in your code to do this.
PHP provides the following conditional statements:

If statement &#8211; execute the piece of code only if a specified condition is true.
if (condition) code to be executed if condition is true;


If&#8230;else statement [...]]]></description>
			<content:encoded><![CDATA[<p>Conditional statements are used to evaluate some conditions and perform different actions based on the outcome.</p>
<p>You can use conditional statements in your code to do this.</p>
<p>PHP provides the following conditional statements:</p>
<ul>
<li>If statement &#8211; execute the piece of code only if a specified condition is true.
<p><span style="color: #808080;">if (condition) code to be executed if condition is true;</span></li>
</ul>
<ul>
<li>If&#8230;else statement – this statement executes a two way condition, where the true part does something else and the false part executes something else.
<p><span style="color: #808080;">if (condition)<br />
code to be executed if condition is true;<br />
else<br />
code to be executed if condition is false;</span></li>
</ul>
<ul>
<li>If&#8230;elseif&#8230;.else statement – if there are multi-way condition, where there are several blocks of code to be executed based on different conditions.
<p><span style="color: #808080;">if (condition)<br />
code to be executed if condition is true;<br />
elseif (condition)<br />
code to be executed if condition is true;<br />
else<br />
code to be executed if condition is false;</span></li>
</ul>
<ul>
<li>Switch statement &#8211; this statement is used to select one of many blocks of code to be executed
<p><span style="color: #808080;">switch (n)<br />
{<br />
case label1:<br />
code to be executed if n=label1;<br />
break;<br />
case label2:<br />
code to be executed if n=label2;<br />
break;<br />
default:<br />
code to be executed if n is different from both label1 and label2;<br />
}</span></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/php-tutorial/conditional-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
