#43769 [Opn->Bgs]: Comparison wrong

From: Date: Sun, 06 Jan 2008 19:16:26 +0000
Subject: #43769 [Opn->Bgs]: Comparison wrong
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121082@lists.php.net to get a copy of this message
ID: 43769 Updated by: felipe@php.net Reported By: hardisc15 at gmail dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 5.2.5 New Comment: 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 Says the documentation: "A key may be either an integer or a string." Therefore, the float value is converted to integer. <?php var_dump(array(1.4 => 'foobar')); /* array(1) { [1]=> string(6) "foobar" } */ Previous Comments: ------------------------------------------------------------------------ [2008-01-06 15:16:05] hardisc15 at gmail dot com Description: ------------ Floating point should have equal treatment of whole number in this example? Sorry, I am using translator. Reproduce code: --------------- $teste=4.1;//$teste='4.1'; $confere=array(4=>''); if(isset($confere[$teste])){echo 'BUG';}else{echo 'NO BUG';} Expected result: ---------------- NO BUG Actual result: -------------- BUG ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43769&edit=1

« previous php.bugs (#121082) next »