You are here: Daniel Dumas »

March, 2009

PHP Operators: The === Operator

PHP’s === Operator enables you to compare or test variables for both equality and type. Refer below for example.

<?php
//define variables..
$str = '9';
$int = 9;

//Returns true since both variable contains the same value..
$res = ($str==$int);

//Returns false since the two variables are not of the same type..
$res = ($str===$int);
?>

PHP Operators : Using Comparison Operators

To compare php variables to determine whether they are the same or different.. you can use PHP Comparison Operators. See below for a list of examples..

I. Define the Variables

<?php
$num1 = 9;
$num2 = 9;
$num3 = 22;
?>

A. The Less Than Operator

<?php
//Returns true if variable in the left side is less than the right..
$res = ($num1 < $num3);
//returns true..
?>

Keep Reading…