ID:               45297
 Updated by:       [EMAIL PROTECTED]
 Reported By:      wittstruck at mediafinanz dot de
-Status:           Open
+Status:           Bogus
 Bug Type:         Strings related
 Operating System: Windows XP
 PHP Version:      5.2.6
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

http://php.net/operators.comparison

if you compare a double with a string, the string is translated to a
double first, use !==.





Previous Comments:
------------------------------------------------------------------------

[2008-06-18 09:17:55] wittstruck at mediafinanz dot de

Description:
------------
I'm casting a string to a double; afterwards the casted result does
differ from the original string, but comparing them does not work
properly and leads to a wrong bool.

strcmp works, though.

Reproduce code:
---------------
<?php

$stringAmount = '2008-06-13 14:24:00';

$doubleAmount = (double) $stringAmount;

echo 'doubleAmount: ' . $doubleAmount . ' stringAmount: ' . 
$stringAmount;

if ($doubleAmount != $stringAmount)
{
    echo '<br/>' . $doubleAmount . ' is not equal to' . $stringAmount;
}
else
{
    echo "<br/> both are equal";
}

?>

Expected result:
----------------
doubleAmount: 2008 stringAmount: 2008-06-13 14:24:00
2008 is not equal to2008-06-13 14:24:00

Actual result:
--------------
doubleAmount: 2008 stringAmount: 2008-06-13 14:24:00
both are equal


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45297&edit=1

Reply via email to