note 108104 added to language.operators.comparison

From: Date: Wed, 28 Mar 2012 20:06:03 +0000
Subject: note 108104 added to language.operators.comparison
Groups: php.notes 
Request: Send a blank email to php-notes+get-186895@lists.php.net to get a copy of this message
Beware of the consequences of comparing strings to numbers. You can disprove the laws of the universe. echo ('X' == 0 && 'X' == true && 0 == false) ? 'true == false' : 'sanity prevails'; This will output 'true == false'. This stems from the use of the UNIX function strtod() to convert strings to numbers before comparing. Since 'X' or any other string without a number in it converts to 0 when compared to a number, 0 == 0 && 'X' == true && 0 == false ---- Server IP: 69.147.83.197 Probable Submitter: 76.164.2.2 ---- Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php Edit -- https://master.php.net/note/edit/108104 Del: integrated -- https://master.php.net/note/delete/108104/integrated Del: useless -- https://master.php.net/note/delete/108104/useless Del: bad code -- https://master.php.net/note/delete/108104/bad+code Del: spam -- https://master.php.net/note/delete/108104/spam Del: non-english -- https://master.php.net/note/delete/108104/non-english Del: in docs -- https://master.php.net/note/delete/108104/in+docs Del: other reasons-- https://master.php.net/note/delete/108104 Reject -- https://master.php.net/note/reject/108104 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186895) next »