note 107481 deleted from language.operators.logical by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 21:06:02 +0000 |
| Subject: | note 107481 deleted from language.operators.logical by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187854@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Regarding [ctulek at gmail dot com 18-Oct-2010 02:07] not dangerous if you use the === operator, or
understand PHP type juggling; adding to your example:
<?php
$a = 0;
$b = 'G';
$c = false;
// 3 lines added ...
var_dump((int) 'G'); // => 0
var_dump((bool) 0); // => false
var_dump((bool) 'G'); // => true
echo ($a == $b) ? "true\n" : "false\n"; // 0 == 0 => true
echo ($a == $c) ? "true\n" : "false\n"; // false == false => true
echo ($c == $b) ? "true\n" : "false\n"; // false == true => false
// 3 lines added ...
echo ($a === $b) ? "true\n" : "false\n"; // => false
echo ($a === $c) ? "true\n" : "false\n"; // => false
echo ($c === $b) ? "true\n" : "false\n"; // => false
?>