note 65484 deleted from function.max by bjori

From: Date: Tue, 02 May 2006 01:43:04 +0000
Subject: note 65484 deleted from function.max by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-110317@lists.php.net to get a copy of this message
Note Submitter: bhook at kssb dot net Reason: in docs ---- During a discussion on IRC we noticed what we thought was an odd behaviour. After looking over the various different tests we produced, we came to the conclusion that the following statement applies to min() and max(): "All arguments are cast to the type of the first value for comparison, but are returned as the type they were passed in as." This becomes most noticed when comparing boolean types to integers. max(true,100) will return differently than max(100,true). Another behaviour that was also observed is that min() and max() will return the first item, in its native type, when multiple values satisfy the condition. This can produce unexpected behaviour if not handled properly. For example, min(false,0) will return (bool)false, where min(0,false) will return (int)0. Hope this takes care of some of the confusion.

« previous php.notes (#110317) next »