Triple Equals Comparison Operator

One hell of a title. What does it mean? You know how you use a double equals (==) to compare two values in php? Well a triple equals (===) compares the values and also compares whether the variables are the same datatype. Sounds pretty useless, no? Consider this:

if ($_REQUEST[name] == ''){
    echo 'variable "name" is empty or undefined';
} else {
    echo 'variable "name" has a value';
}

And compare it to this:

if ($_REQUEST[name] === ''){
    echo 'variable "name" is empty';
} else {
    echo 'variable "name" has a value or is undefined.';
}

Wild.

Advertisements

About Mr Chimp

I make music, draw pictures, browse the internet, programme, and make sweet, sweet cups of tea until the early hours.
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s