Comparing non-empty string and 0 - is this behavior to be expected?
| From: | Jeremy O'Connor | Date: | Sun, 05 Apr 2020 06:38:34 +0000 |
| Subject: | Comparing non-empty string and 0 - is this behavior to be expected? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-327090@lists.php.net to get a copy of this message | ||
Looking at the following code
echo ('') ? 'T' : 'F';
echo ('!') ? 'T' : 'F';
echo (0) ? 'T' : 'F';
echo ('' == 0) ? 'T' : 'F';
echo ('!' == 0) ? 'T' : 'F';
the output is:
FTFTT
Is this behavior to be expected?
--
Jeremy O'Connor