note 27693 added to function.max

From: Date: Mon, 16 Dec 2002 11:35:53 +0000
Subject: note 27693 added to function.max
Groups: php.notes 
Request: Send a blank email to php-notes+get-40951@lists.php.net to get a copy of this message
Apparently max() thinks false is greater than 0... example: if(max(false,0)==false) echo "blah"; this proves a problem when comparing with values from a database if these values doesn't exist and you need 0 instead of false. a workaround is to cast the values to int's, so max((int)false,0) returns 0 as it should -- http://www.php.net/manual/en/function.max.php http://master.php.net/manage/user-notes.php?action=edit+27693 http://master.php.net/manage/user-notes.php?action=delete+27693 http://master.php.net/manage/user-notes.php?action=reject+27693

« previous php.notes (#40951) next »