<?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>Marc Fraser &#124; A Blog about all things &#187; comparison</title>
	<atom:link href="http://www.marcfraser.co.uk/tag/comparison/feed" rel="self" type="application/rss+xml" />
	<link>http://www.marcfraser.co.uk</link>
	<description>A blog about all things personal, web related.</description>
	<lastBuildDate>Fri, 23 Apr 2010 13:50:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Operators</title>
		<link>http://www.marcfraser.co.uk/php-operators-58.htm</link>
		<comments>http://www.marcfraser.co.uk/php-operators-58.htm#comments</comments>
		<pubDate>Sat, 10 Oct 2009 10:30:42 +0000</pubDate>
		<dc:creator>Marc</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[arithmetic operators]]></category>
		<category><![CDATA[assignment operators]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[php comparison operators]]></category>
		<category><![CDATA[string operators]]></category>

		<guid isPermaLink="false">http://marcfraser.co.uk/?p=58</guid>
		<description><![CDATA[(from Full Article)
Here are most types of PHP Operators: Assignment Operators, Arithmetic Operators, Comparison Operators, and String Operators.
Assignment Operators
We have already met this type. This is where we set a variable equal to something or make a variable equal to another variable.
Arithmetic Operators



English 
Operator
Example


Addition
+
1+1


Subtraction
-
5-3


Multiplication
*
5*2


Division
/
10/2



An example of the use of Arithmetic operators is shown below:
&#60;?php

$add = [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em><strong><em></em></strong></em></strong><strong><em><strong><em><a href="../introduction-to-php-tutorial-9.htm">(from Full Article)</a></em></strong></em></strong></p>
<p>Here are most types of PHP Operators: Assignment Operators, Arithmetic Operators, Comparison Operators, and String Operators.</p>
<p><span style="text-decoration: underline;">Assignment Operators</span></p>
<p>We have already met this type. This is where we set a variable equal to something or make a variable equal to another variable.</p>
<p><span style="text-decoration: underline;">Arithmetic Operators</span></p>
<table style="height: 83px;" border="1" cellspacing="0" cellpadding="0" width="278">
<tbody>
<tr>
<td width="142" valign="top"><strong>English </strong></td>
<td width="142" valign="top"><strong>Operator</strong></td>
<td width="142" valign="top"><strong>Example</strong></td>
</tr>
<tr>
<td width="142" valign="top">Addition</td>
<td width="142" valign="top">+</td>
<td width="142" valign="top">1+1</td>
</tr>
<tr>
<td width="142" valign="top">Subtraction</td>
<td width="142" valign="top">-</td>
<td width="142" valign="top">5-3</td>
</tr>
<tr>
<td width="142" valign="top">Multiplication</td>
<td width="142" valign="top">*</td>
<td width="142" valign="top">5*2</td>
</tr>
<tr>
<td width="142" valign="top">Division</td>
<td width="142" valign="top">/</td>
<td width="142" valign="top">10/2</td>
</tr>
</tbody>
</table>
<p>An example of the use of Arithmetic operators is shown below:</p>
<pre class="brush: php;">&lt;?php

$add = 1+1;

$subtract = 5-3;

$multiply = 5*2;

$divide = 10/2;

print “Addition Answer: ” . $add . “&lt;br&gt;”;

print “Subtraction Answer: ” . $subtract. “&lt;br&gt;”;

print “Multiplication Answer: ” . $multiply. “&lt;br&gt;”;

print “Addition Answer: ” . $divide. “&lt;br&gt;”;

?&gt;</pre>
<p>The output of the above code is:</p>
<blockquote><p>Addition Answer: 2<br />
Subtraction Answer: 2<br />
Multiplication Answer: 10<br />
Addition Answer: 5</p></blockquote>
<p>This showing that the server is carrying out the calculations, using our arithmetic operators. As well as the above, you could also use these operators in conjunction with each other like so:</p>
<pre class="brush: php;">&lt;?php

$quantity = 4;

$value = 5;

$total = $quantity * $value;

print $total;

?&gt;</pre>
<p>The output from the above is 20.</p>
<p><span style="text-decoration: underline;">Comparison Operators</span></p>
<p>Comparison Operators are used to check the relationship between variables/values. These are used inside statements (such as if statements) to check whether the result is true or false. Listed are some PHP comparison operators:</p>
<p><em>We will assume, for this example, that $a = 2 and $b = 3.</em></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="134" valign="top"><strong>English</strong></td>
<td width="71" valign="top"><strong>Operator</strong></td>
<td width="99" valign="top"><strong>Example</strong></td>
<td width="99" valign="top"><strong>Result</strong></td>
</tr>
<tr>
<td width="134" valign="top">Equal to</td>
<td width="71" valign="top">==</td>
<td width="99" valign="top">$a == $b</td>
<td width="99" valign="top">False</td>
</tr>
<tr>
<td width="134" valign="top">Not equal to</td>
<td width="71" valign="top">!=</td>
<td width="99" valign="top">$a != $b</td>
<td width="99" valign="top">True</td>
</tr>
<tr>
<td width="134" valign="top">Less than</td>
<td width="71" valign="top">&lt;</td>
<td width="99" valign="top">$a &lt; $b</td>
<td width="99" valign="top">True</td>
</tr>
<tr>
<td width="134" valign="top">Greater than</td>
<td width="71" valign="top">&gt;</td>
<td width="99" valign="top">$a &gt; $b</td>
<td width="99" valign="top">False</td>
</tr>
<tr>
<td width="134" valign="top">Less than or equal to</td>
<td width="71" valign="top">&lt;=</td>
<td width="99" valign="top">$a &lt;= $b</td>
<td width="99" valign="top">True</td>
</tr>
<tr>
<td width="134" valign="top">Greater than or equal to</td>
<td width="71" valign="top">&gt;=</td>
<td width="99" valign="top">$a &gt;= $b</td>
<td width="99" valign="top">False</td>
</tr>
</tbody>
</table>
<p>Please note the two equal signs in the equal to example – this is a common beginners’ mistake.</p>
<p>We will go into further examples of Comparison Operators in the next section on <em>PHP If Statements</em>.</p>
<p><span style="text-decoration: underline;">String Operators</span></p>
<p>We have already met String Operators, please read prior section named <em>Concatenation.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcfraser.co.uk/php-operators-58.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
