note 72199 modified in language.operators.comparison by danbrown

From: Date: Thu, 18 Jun 2009 14:06:14 +0000
Subject: note 72199 modified in language.operators.comparison by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157070@lists.php.net to get a copy of this message
Note that typecasting will NOT prevent the default behavior for converting two numeric strings to numbers when comparing them. e.g.: <?php if ((string) '0123' == (string) '123') print 'equals'; else print 'doesn\'t equal'; ?> Still prints 'equals' As far as I can tell the only way to avoid this is to use the identity comparison operators (=== and !==). --was-- Note that typecasting will NOT prevent the default behavior for converting two numeric strings to numbers when comparing them. e.g.: if ((string) '0123' == (string) '123') print 'equals'; else print 'doesn\'t equal'; Still prints 'equals' As far as I can tell the only way to avoid this is to use the identity comparison operators (=== and !==). http://php.net/manual/en/language.operators.comparison.php

« previous php.notes (#157070) next »