php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48935 Comparison output
Submitted: 2009-07-15 20:51 UTC Modified: 2009-07-15 21:10 UTC
From: ultigma at hotmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.10 OS: Vista
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ultigma at hotmail dot com
New email:
PHP Version: OS:

 

 [2009-07-15 20:51 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-15 20:53 UTC] 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:59 UTC] 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 21:10 UTC] ultigma at hotmail dot com
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'?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC