ID: 36938 User updated by: daniele_dll at yahoo dot it Reported By: daniele_dll at yahoo dot it -Status: Bogus +Status: Open Bug Type: Scripting Engine problem Operating System: Windows XP SP2 - Fedora Core 4 PHP Version: 5.1.2 New Comment:
ops, forgotten to re-open the report sorry Previous Comments: ------------------------------------------------------------------------ [2006-04-01 09:33:18] daniele_dll at yahoo dot it I'll try to explain me ... $value = 'qwerty'; $value -> qwerty (int)$value -> 0 so ... how can be that 0 is equal to qwerty? Try this code too <?php $valore = 'qwerty'; $_v = intval($valore); echo ($valore) ? 'true ' : 'false '; echo ($_v) ? 'true ' : 'false '; if ($valore == $_v) { echo "variable ({$valore}) contains a valid numeric value ({$_v}) !"; } else { echo "variable doesn't contains a valid numeric value!"; } ?> The result is wrong! ------------------------------------------------------------------------ [2006-03-31 23:25:52] [EMAIL PROTECTED] 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 ------------------------------------------------------------------------ [2006-03-31 23:17:23] daniele_dll at yahoo dot it Description: ------------ Type casting a value on an if doesn't work! If i compare a string value with the same value type casted to an int and this string doesn't contains a numeric value i recive a true from the boolean expression! I've tried many combinations but all return the same result Thanks for the help Reproduce code: --------------- <?php $valore = 'qwerty'; if ($valore == (int)$valore) { echo "variable contains a valid numeric value!"; } else { echo "variable doesn't contains a valid numeric value!"; } ?> Expected result: ---------------- $valore == (int)$valore --> FALSE variable doesn't contains a valid numeric value! Actual result: -------------- $valore == (int)$valore --> TRUE variable contains a valid numeric value! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36938&edit=1