Ok, I know what:
= is
and I know what
== is
but what in the world is:
===
???
ie
if ($foo === $bar) {
Thanks.
| SitePoint Sponsor |


Ok, I know what:
= is
and I know what
== is
but what in the world is:
===
???
ie
if ($foo === $bar) {
Thanks.





i believe it's equivalent to == (the logically equal-to)
http://www.php.net/manual/en/languag...comparison.php
it compares the equality and type (PHP 4 only).
run this:
output:PHP Code:$a = 0;
$b = '0';
if ($a == $b) { echo "They're equal.<br />"; }
if ($a !== $b) { echo "They're not equal."; }
They're equal.
They're not equal.
- Matt
Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
"Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR
In loosely-typed languages such as PHP and Perl, the interpreter will cast a value to the required type according to the context of its use. So we often don't think about what type our variables have because it is mainly irrelevent to how we code. But the underlying type is there (int, string, double, float, null, etc).
In Dr Peper's example $a will have a type of int or real (not sure - I would have to check the manual ) and $b would have a type of string.
There may be times when we need to deal more strictly with a variable's type in our code. We may need to check for a variable's type. Thus the functions is_null(), is_int(), etc. Which help us determine the type of a variable.
As Dr Pepper has already suggested, we can also test for equalitly of value AND type using the === and !== operators.


Wow, Thanks guys!
I finally understand![]()
Checking for type, that is ingenious!
Again, thanks!
Bookmarks