Re: diference between == and ===
| From: | John W. Holmes | Date: | Mon, 03 May 2004 14:33:08 +0000 |
| Subject: | Re: diference between == and === | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-34257@lists.php.net to get a copy of this message | ||
From: "Bruno Braga" <bbraga@neworange.com.pt>
> == 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...