Comments on: Equal Sign in PHP: Equality and Not Equals https://phpreferencebook.com/samples/equal-sign-operators/ PHP Reference: Beginner to Intermediate PHP5 Wed, 07 Sep 2011 23:05:47 +0000 hourly 1 https://wordpress.org/?v=4.9.13 By: Lawrence https://phpreferencebook.com/samples/equal-sign-operators/comment-page-1/#comment-1934 Tue, 12 Jul 2011 09:12:49 +0000 https://phpreferencebook.com/?p=153#comment-1934 Thanks, now I understand that double equal signs compare while triple equals signs compare if identical data type in addition to the value

]]>
By: Geoff Birt https://phpreferencebook.com/samples/equal-sign-operators/comment-page-1/#comment-1610 Wed, 25 Aug 2010 05:26:16 +0000 https://phpreferencebook.com/?p=153#comment-1610 Matt,
I was left wondering what the diff was until I read your comment. Thank you for making that clear. Hope they add that info to the article.

]]>
By: Matt Borja https://phpreferencebook.com/samples/equal-sign-operators/comment-page-1/#comment-1543 Fri, 23 Jul 2010 07:38:16 +0000 https://phpreferencebook.com/?p=153#comment-1543 “Identical ( === ): Checks if the left and right values are equal AND identical”

It is also worth clarifying that the word “identical” is referring to comparison of variable data types. While using double equal signs (==) is appropriate for comparing the contents of two variables, using triple equal signs (===) is intended not only for comparing the contents of two variables, but comparing the data type (or the type of each variable).

The first example was a good illustration of this in the comments where variable $a is assigned an integer (int) value of 1 and variable $b was assigned a boolean (bool) value of TRUE.

Always remember that the data type of a variable is being set automatically by the *type* of value you assign it, whether it be integer (int), floating point (float), associative array (array), boolean (bool), class object (object) or even a resource (as in the case of MySQL queries). Therefore, use of the triple equal sign (===) for comparison is most appropriate when data types matter.

]]>
By: Camnio Media https://phpreferencebook.com/samples/equal-sign-operators/comment-page-1/#comment-1292 Tue, 12 Jan 2010 06:11:01 +0000 https://phpreferencebook.com/?p=153#comment-1292 Thanks for the reference, I’m working on a php project.

]]>