Changes

Jump to: navigation, search

PHP Operators

1,061 bytes added, 13:09, 31 May 2007
PHP Comparison Operators
<td>==<td>Equal to<td>Returns ''true'' if first operand equals second<td>$myVar = 10; <br>if ($myVar == 10)<br>echo 'myVar equals 10';</td>
<tr>
<td>!=<td>Not equal to<td>Returns ''true'' if first operand is not equal to second<td>$myVar = 10; <br>if ($myVar !== 1020)<br>echo 'myVar equals does not equal 10';</td>
<tr>
<td>===<td>Equal Identical to<td>Returns ''true'' if first operand equals second in both value and type<td>$myVar = 10;<br>$myString="10"; <br>if ($myVar === $myString)<br>echo 'myVar and myString are same type and value';</td><tr><td>!==<td>Not identical to<td>Returns ''true'' if first operand is not identical to second in both value and type<td>$myVar = 10;<br>$myString="10"; <br>if ($myVar !== $myString)<br>echo 'myVar and myString are not same type and value';</td><tr><td><<td>Less than<td>Returns ''true'' if the value of the first operand is less than the second<td>$myVar = 10; <br>if ($myVar < 20)<br>echo 'myVar if less than 20';</td><tr><td>><td>Greater than<td>Returns ''true'' if the value of the first operand is greater than the second<td>$myVar = 10; <br>if ($myVar > 5)<br>echo 'myVar if greater than 5';</td><tr><td><=<td>Less than or equal to<td>Returns ''true'' if the value of the first operand is less than, or equal to, the second<td>$myVar = 10; <br>if ($myVar <= 5)<br>echo 'myVar is less than or equal to 5';</td><tr><td>>=<td>Greater than or equal to<td>Returns ''true'' if the value of the first operand is greater than, or equal to, the second<td>$myVar = 10; <br>if ($myVar >= 5)<br>echo 'myVar is greater than or equal to 5';</td> 
</table>

Navigation menu