#48935 [Bgs]: Comparison output
| From: | ultigma at hotmail dot com | Date: | Wed, 15 Jul 2009 21:10:08 +0000 |
| Subject: | #48935 [Bgs]: Comparison output | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-139773@lists.php.net to get a copy of this message | ||
ID: 48935
User updated by: ultigma at hotmail dot com
Reported By: ultigma at hotmail dot com
Status: Bogus
Bug Type: Feature/Change Request
Operating System: Vista
PHP Version: 5.2.10
New Comment:
Oh yea, i wasn't sure if this was the right place to post this, but
that's what i was looking for. Is there any way to set this as a
default
option so it just displays that without ?'True':'False'?
Previous Comments:
------------------------------------------------------------------------
[2009-07-15 20:59:55] rasmus@php.net
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.
------------------------------------------------------------------------
[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