note 78983 added to language.types.string

From: Date: Tue, 06 Nov 2007 00:48:19 +0000
Subject: note 78983 added to language.types.string
Groups: php.notes 
Request: Send a blank email to php-notes+get-132023@lists.php.net to get a copy of this message
I have come across this several times, and as far as I can tell, the < and > operators have undocumented functionality when it comes to comparing strings. Consider the following script: <?php $a = '2007-11-05 15:17:49'; $b = '2007-11-05 15:17:48'; $bool = $a > $b; var_dump($bool); //bool(true) /** * The manual tells us that $a and $b should be * truncated at -, thus giving a floating-point value of 2007. * But (2007 > 2007) === false... */ $a = (float)$a; $b = (float)$b; var_dump($a); //float(2007); var_dump($b); //float(2007); /** * And the manual is right. So why does it correctly * compare the dates (which should be treated * as normal strings? Clearly some hidden functionality... */ ---- Server IP: 208.69.120.35 Probable Submitter: 131.128.137.187 ---- Manual Page -- http://www.php.net/manual/en/language.types.string.php Edit -- https://master.php.net/note/edit/78983 Del: integrated -- https://master.php.net/note/delete/78983/integrated Del: useless -- https://master.php.net/note/delete/78983/useless Del: bad code -- https://master.php.net/note/delete/78983/bad+code Del: spam -- https://master.php.net/note/delete/78983/spam Del: non-english -- https://master.php.net/note/delete/78983/non-english Del: in docs -- https://master.php.net/note/delete/78983/in+docs Del: other reasons-- https://master.php.net/note/delete/78983 Reject -- https://master.php.net/note/reject/78983 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132023) next »