#48935 [Opn->Bgs]: Comparison output
| From: | rasmus@php.net | Date: | Wed, 15 Jul 2009 20:59:55 +0000 |
| Subject: | #48935 [Opn->Bgs]: Comparison output | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-139772@lists.php.net to get a copy of this message | ||
ID: 48935
Updated by: rasmus@php.net
Reported By: ultigma at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Vista
PHP Version: 5.2.10
New Comment:
For display purposes true is 1 and false is an empty string.
The normal way to display True/False strings is like this:
echo ($num==$num2) ? 'True' : 'False';
This is a support request, not a bug.
Previous Comments:
------------------------------------------------------------------------
[2009-07-15 20:53:09] ultigma at hotmail dot com
Forgot to add, How can i change the result from 0 and 1 to False and
True?
------------------------------------------------------------------------
[2009-07-15 20:51:30] ultigma at hotmail dot com
Description:
------------
New to PHP but I'm sure this is just a small problem but i can't find
a
solution to it anywhere. Comparisons that equate to false are not
returned to the browser at all and True values are displayed as 1.
I would have thought that, like most languages ($num1 == $num2) would
return False.
Reproduce code:
---------------
<?php
$num1 = 8;
$num2 = 21;
echo "Is " . $num1 . " equal to " . $num2 . " = " . ($num1 == $num2);
echo "<br />Is " . $num1 . " less than " . $num2 . " = " .
($num1 <
$num2);
echo "<br />Is " . $num1 . " greater than " . $num2 . " = " .
($num1 >
$num2);
echo "<br />Is " . $num1 . " less than or equal to " . $num2 . " =
" .
($num1 <= $num2);
?>
Expected result:
----------------
Is 8 equal to 21 = False
Is 8 less than 21 = True
Is 8 greater than 21 = False
Is 8 less than or equal to 21 = True
Actual result:
--------------
Is 8 equal to 21 =
Is 8 less than 21 = 1
Is 8 greater than 21 =
Is 8 less than or equal to 21 = 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48935&edit=1