Bug #77928 [Com]: echo ('string'==0)?"TRUE":"FALSE"; // TRUE
| From: | spam2 at rhsoft dot net | Date: | Sun, 21 Apr 2019 09:44:11 +0000 |
| Subject: | Bug #77928 [Com]: echo ('string'==0)?"TRUE":"FALSE"; // TRUE | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220547@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77928&edit=1
ID: 77928
Comment by: spam2 at rhsoft dot net
Reported by: shamil dot kur at gmail dot com
Summary: echo ('string'==0)?"TRUE":"FALSE"; // TRUE
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Debian
PHP Version: 7.3.4
Block user comment: N
Private report: N
New Comment:
what about reading a php documentation for beginners and start using === instead spam bug trackers?
Previous Comments:
------------------------------------------------------------------------
[2019-04-21 06:28:27] shamil dot kur at gmail dot com
Or do you want to say that when comparing with int, any string == 0? If so, then the question is
closed. But "8"==8, "0"==0, "7"==7, "7"!=8 but
"7"==0
------------------------------------------------------------------------
[2019-04-21 06:23:44] shamil dot kur at gmail dot com
If decided that this is not an error. That does not equate \0 to any string. Let it always be not
equal. Because, it is ambiguity.
Is this logical?
<?php
if("any string"==0)echo "this\n";
if("\0"==0)echo "and this\n";
//Result:
this
end this
------------------------------------------------------------------------
[2019-04-21 06:14:33] shamil dot kur at gmail dot com
// You are joking?
// It violates the laws of logic.
$a=0;
$b='string 1';
$Ñ='string 2';
if(($a==$b) && ($a==$c))echo "\$b==\$c";
// But $b don't eq $c.
if($b!=$c)echo "\$b!=\$c";
------------------------------------------------------------------------
[2019-04-20 18:53:02] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
------------------------------------------------------------------------
[2019-04-20 18:22:33] spam2 at rhsoft dot net
Expected:
echo ('string'==0)?"TRUE":"FALSE"; // FALSE - OK
fix your expectations!
'string'==0 evaluates to TRUE
php > echo ('string'==0);
1
php > echo ('string'===0);
php >
that's how PHP works all the time
https://www.php.net/manual/en/language.types.type-juggling.php
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=77928
--
Edit this bug report at https://bugs.php.net/bug.php?id=77928&edit=1