php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68649 ECHO
Submitted: 2014-12-24 22:27 UTC Modified: 2014-12-26 05:22 UTC
From: vusalhaqverdiyev at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.4Git-2014-12-24 (Git) OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vusalhaqverdiyev at gmail dot com
New email:
PHP Version: OS:

 

 [2014-12-24 22:27 UTC] 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"

Patches

VusalPatch (last revision 2014-12-24 22:31 UTC by vusalhaqverdiyev at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-26 00:40 UTC] php at mcq8 dot be
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)
 [2014-12-26 05:22 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-12-26 05:22 UTC] 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


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 22:00:02 2026 UTC