Bug #68649 [Com]: ECHO
| From: | php at mcq8 dot be | Date: | Fri, 26 Dec 2014 00:40:47 +0000 |
| Subject: | Bug #68649 [Com]: ECHO | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189206@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68649&edit=1
ID: 68649
Comment by: php at mcq8 dot be
Reported by: vusalhaqverdiyev at gmail dot com
Summary: ECHO
Status: Open
Type: Bug
Package: *General Issues
Operating System: Linux
PHP Version: 5.4Git-2014-12-24 (Git)
Block user comment: N
Private report: N
New Comment:
This is not a bug.
The echo of FALSE RESULT is due to type
juggling.(http://php.net/manual/en/language.types.type-juggling.php)
The string "test" gets converted to 0.
You can use if($a === "test"){ to compare types as well.
(http://be2.php.net/manual/en/language.operators.comparison.php)
Previous Comments:
------------------------------------------------------------------------
[2014-12-24 22:27:50] vusalhaqverdiyev at gmail dot com
Description:
------------
$a = 0;
if($a == "test"){
echo "FALSE RESULT";
}
else{
echo "TRUE RESULT";
}
In this code snippet, $a = 0, and the "if" must not launch. But "if" is
launched.
Test script:
---------------
$a = 0;
if($a == "test"){
echo "FALSE RESULT";
}
else{
echo "TRUE RESULT";
}
In this code snippet, $a = 0, and the "if" must not launch. But "if" is
launched.
Expected result:
----------------
$a = 0;
if($a == "test"){
echo "FALSE RESULT";
}
else{
echo "TRUE RESULT";
}
In this code result must be "True result"
Actual result:
--------------
$a = 0;
if($a == "test"){
echo "FALSE RESULT";
}
else{
echo "TRUE RESULT";
}
In this code result must be "True result"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68649&edit=1