Re: diference between == and ===

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Bruno Braga" <bbraga@xxxxxxxxxxxxxxxx>

> == means equality and what does the === means ?!

It matches the variable type, too.

$a = 1;

if($a == '1') => TRUE

if($a === '1') => FALSE

Most often used for function that can return a number including zero and
FALSE. If you're expecting a number to be returned and checking with

$a = somefunction();
if($a)

then it'll fail when zero is returned even though it's a valid value. So
you'd use

if($a === FALSE)

or

if($a !== FALSE)

to see whether the function truly failed or not.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux