<?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>Capable SEO &#187; programming</title>
	<atom:link href="http://www.capableseo.com/tag/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://www.capableseo.com</link>
	<description></description>
	<lastBuildDate>Mon, 12 Apr 2010 08:42:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>If Then Math PHP Statements</title>
		<link>http://www.capableseo.com/if-then-math-php-statements.html</link>
		<comments>http://www.capableseo.com/if-then-math-php-statements.html#comments</comments>
		<pubDate>Wed, 15 Jul 2009 04:43:02 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.capableseo.com/?p=49</guid>
		<description><![CDATA[
Lets get started by opening your favorite editor and starting a fresh source page. Start off with the basic coding which denotes a php area. &#60;?php ?&#62;
Now lets add in some basic variables and an echo statement. Give two variables a value of 2, and a third variable a value equal to the previous to [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>Lets get started by opening your favorite editor and starting a fresh source page. Start off with the basic coding which denotes a php area. <span>&lt;?php ?&gt;</span></li>
<li>Now lets add in some basic variables and an echo statement. Give two variables a value of 2, and a third variable a value equal to the previous to variables added together.<br />
<table border="0" cellspacing="0" cellpadding="0" width="350" bgcolor="#cccccc">
<tbody>
<tr>
<td><code><span style="color: #000000;"> <span style="color: #0000bb;">&lt;?php<br />
$x</span><span style="color: #007700;">=</span><span style="color: #0000bb;">2</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$y</span><span style="color: #007700;">=</span><span style="color: #0000bb;">2</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$number</span><span style="color: #007700;">=</span><span style="color: #0000bb;">$x</span><span style="color: #007700;">+</span><span style="color: #0000bb;">$y</span><span style="color: #007700;">;<br />
echo </span><span style="color: #0000bb;">$number</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">?&gt;<br />
</span> </span> </code></td>
</tr>
</tbody>
</table>
<p>This should print out <span>4</span> .</li>
<li>Try changing the <span>+</span> to different mathmatical operators these are:<br />
<span>/</span> Divide<br />
<span>*</span> Multiply<br />
<span>-</span> Subtract</li>
<li>Now we&#8217;re going to add in an if then statement. Basically if statements are logical, if certain requirements are met then do something. An if then statement looks like this<br />
<table border="0" cellspacing="0" cellpadding="0" width="350" bgcolor="#cccccc">
<tbody>
<tr>
<td><code><span style="color: #000000;"> <span style="color: #0000bb;">&lt;?php<br />
</span><span style="color: #007700;">if (</span><span style="color: #ff8000;">/*requirements*/</span><span style="color: #007700;">)<br />
{<br />
</span><span style="color: #ff8000;">//Stuff to do<br />
</span><span style="color: #007700;">}<br />
</span><span style="color: #0000bb;">?&gt;<br />
</span> </span> </code></td>
</tr>
</tbody>
</table>
<p>The if statement is one of the few that doesn&#8217;t require a <span>;</span> after it.</li>
<li>Now lets a simple statement that says, &#8216;if&#8217; <span>&#8216;$number</span> is not equal to four&#8217; &#8216;echo Thats not Four&#8217;. This code looks like this.<br />
<table border="0" cellspacing="0" cellpadding="0" width="350" bgcolor="#cccccc">
<tbody>
<tr>
<td><code><span style="color: #000000;"> <span style="color: #0000bb;">&lt;?php<br />
$x</span><span style="color: #007700;">=</span><span style="color: #0000bb;">1</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$y</span><span style="color: #007700;">=</span><span style="color: #0000bb;">2</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$number</span><span style="color: #007700;">=</span><span style="color: #0000bb;">$x</span><span style="color: #007700;">+</span><span style="color: #0000bb;">$y</span><span style="color: #007700;">;</p>
<p>if (</span><span style="color: #0000bb;">$number</span><span style="color: #007700;">!=</span><span style="color: #0000bb;">4</span><span style="color: #007700;">)<br />
{<br />
echo </span><span style="color: #dd0000;">"Thats not Four"</span><span style="color: #007700;">;<br />
}<br />
</span><span style="color: #0000bb;">?&gt;<br />
</span> </span> </code></td>
</tr>
</tbody>
</table>
<p>This should print out &#8220;<span>Thats not Four</span>&#8221;</p>
<p>The comparison operators in PHP are as follows:<br />
<span>!=</span> Is not equal to<br />
<span>==</span> Equal to<br />
<span>&gt;</span> Greater than<br />
<span>&lt;</span> Less than<br />
<span>&gt;=</span> Greater than or Equal to<br />
<span>&lt;=</span> Greater than or Equal to</li>
<li>Now lets say you want to check if the number is between 5 and 10. You&#8217;ll need to use two checks in the if instead of one. So you need to say &#8216;if&#8217; <span>&#8216;$number</span> is greater than or equal to 5 and less than or equal to 10&#8242; &#8216;echo number is between 5 and 10&#8242;. The code for this looks like this:<br />
<table border="0" cellspacing="0" cellpadding="0" width="350" bgcolor="#cccccc">
<tbody>
<tr>
<td><code><span style="color: #000000;"> <span style="color: #0000bb;">&lt;?php<br />
$x</span><span style="color: #007700;">=</span><span style="color: #0000bb;">1</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$y</span><span style="color: #007700;">=</span><span style="color: #0000bb;">2</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$number</span><span style="color: #007700;">=</span><span style="color: #0000bb;">$x</span><span style="color: #007700;">+</span><span style="color: #0000bb;">$y</span><span style="color: #007700;">;</p>
<p>if (</span><span style="color: #0000bb;">$number</span><span style="color: #007700;">&gt;=</span><span style="color: #0000bb;">5 </span><span style="color: #007700;">&amp;&amp; </span><span style="color: #0000bb;">$number</span><span style="color: #007700;">&lt;=</span><span style="color: #0000bb;">10</span><span style="color: #007700;">)<br />
{<br />
echo </span><span style="color: #dd0000;">"number is between 5 and 10"</span><span style="color: #007700;">;<br />
}<br />
</span><span style="color: #0000bb;">?&gt;<br />
</span> </span> </code></td>
</tr>
</tbody>
</table>
<p>This shouldn&#8217;t print anything</p>
<p>Logical Operators for PHP<br />
<span>&amp;&amp;</span> and<br />
<span>||</span> or</li>
<li>Now this is fine and all except what, happens when your number doesn&#8217;t fit the criteria? Nothing happens. So lets add on the final part of an If Then statement. So now PHP will go if <span>$number</span> is between 5-10 do this, or else do this. The code looks like this:<br />
<table border="0" cellspacing="0" cellpadding="0" width="350" bgcolor="#cccccc">
<tbody>
<tr>
<td><code><span style="color: #000000;"> <span style="color: #0000bb;">&lt;?php<br />
$x</span><span style="color: #007700;">=</span><span style="color: #0000bb;">1</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$y</span><span style="color: #007700;">=</span><span style="color: #0000bb;">2</span><span style="color: #007700;">;<br />
</span><span style="color: #0000bb;">$number</span><span style="color: #007700;">=</span><span style="color: #0000bb;">$x</span><span style="color: #007700;">+</span><span style="color: #0000bb;">$y</span><span style="color: #007700;">;</p>
<p>if (</span><span style="color: #0000bb;">$number</span><span style="color: #007700;">&gt;=</span><span style="color: #0000bb;">5 </span><span style="color: #007700;">&amp;&amp; </span><span style="color: #0000bb;">$number</span><span style="color: #007700;">&lt;=</span><span style="color: #0000bb;">10</span><span style="color: #007700;">)<br />
{<br />
echo </span><span style="color: #dd0000;">"number is between 5 and 10"</span><span style="color: #007700;">;<br />
}<br />
else<br />
{<br />
echo </span><span style="color: #dd0000;">"number is less then 5 or greater than 10"</span><span style="color: #007700;">;<br />
}<br />
</span><span style="color: #0000bb;">?&gt;<br />
</span> </span> </code></td>
</tr>
</tbody>
</table>
<p>This should print <span>number is less then 5 or greater than 10</span></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.capableseo.com/if-then-math-php-statements.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
