Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Basics (Retired) PHP Operators PHP Operators

John Hartney
John Hartney
2,893 Points

I dont get this, am I missing somthing?

           var_dump( $a == $b); // equal
var_dump( $a == $d); // identical
var_dump( $a != $b); // not equal
 var_dump( $a !== $b); // not identical

I am getting false no matter what I chose

alt text

3 Answers

Hugo Paz
Hugo Paz
15,622 Points

Hi John,

Identical uses triple equal signs ===

I you look at your examples, non identical is not the same as non equal, it has an extra equal. You should update your example so identical uses triple equals.

John Hartney
John Hartney
2,893 Points

Thanks Hugo,

my new glasses are causing me to make so many mistakes and resizing the treehouse videos is less than perfect, anyone got a spare set of eyes going cheap? lol

=== comparison operator is for something being identical. It's called a strict equality operator.

Example:

"Hello" == "HEllo" ... is true but "Hello" === HEllo" is false

John Hartney
John Hartney
2,893 Points

Hay dave,

gave "Best Answer" to Hugo he was the first but I appreciate you example, thanks a bunch. : )

No prob.

Hugo is exactly right,

== means equal === means identical

This is due to typecasting in PHP. Identity comparisons (===) ensure that equal values are of the same type. Equality comparisons (==) just tests value.

For example:
0 == FALSE would resolve to true because FALSE is the boolean equivalent value to integer 0.

Conversely: 0 === FALSE would resolve to false because integers are not identical to boolean values.

Hope that helps.

John Hartney
John Hartney
2,893 Points

That makes a lot of sense & thanks to all...

I wish I could get this kind of help with this post, I paused my account as I could not work out why the Carousel is not working and my wife needs this site for her e-portfolio