ID: 26821 Comment by: skissane at ics dot mq dot edu dot au Reported By: ivo at benetech dot org Status: Open Bug Type: Documentation problem Operating System: Linux / RH 7.3 PHP Version: 4.3.4 New Comment:
Vrana: your comment makes no sense. If "NANC" is converted to 0, then 0 < 0 would be FALSE, not true. Compare these expressions: "NANC" < 0 result TRUE "NANC" < "0" result FALSE 0 < 0 result FALSE So it seems it is neither converting "NANC" to an integer 0, nor 0 to a string "0". What actually is going on? The documentation should clarify this. Previous Comments: ------------------------------------------------------------------------ [2004-01-07 13:20:58] ivo at benetech dot org It also print 0 as expected. if( (int) "NANC" < 0) also evaluates as expected. ------------------------------------------------------------------------ [2004-01-07 05:53:18] [EMAIL PROTECTED] "NANC" is converted to 0 for comparison. It works for me as expected. What is printed by the code <?php echo intval("NANC"); ?> on your system? ------------------------------------------------------------------------ [2004-01-06 18:08:12] ivo at benetech dot org Documentation needs to be more explicit about php being strongly typed. http://www.php.net/manual/en/language.types.type-juggling.php or http://www.php.net/manual/en/language.types.string.php#language.types.string.conversion ------------------------------------------------------------------------ [2004-01-06 17:23:58] [EMAIL PROTECTED] RTFM: http://www.php.net/manual/en/types.comparisons.php (never ever compare different types like that) ------------------------------------------------------------------------ [2004-01-06 16:28:47] ivo at benetech dot org Description: ------------ The statement... if("NANC" < 0) ...always evaluates TRUE. Reproduce code: --------------- if("NANC" < 0) { print("should not happen...but does\n"); } else { print("should happen...but doesnt\n"); } Expected result: ---------------- echoed to the console: should happen...but doesnt Actual result: -------------- echoed to the console: should not happen...but does ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26821&edit=1