Re: min/max oddities
| From: | Andi Gutmans | Date: | Sun, 07 Nov 1999 19:40:02 +0000 |
| Subject: | Re: min/max oddities | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-5939@lists.php.net to get a copy of this message | ||
At 06:12 PM 11/7/99 +0100, Thies C. Arntzen wrote:
leon just reported a bug in min() and max() (PHP 3 and PHP 4 behave different). the problem is even "bigger": <? var_dump(min(5,1,10, "hello")); var_dump(min(array(5,1,10, "hello"))); var_dump(max(1,10, "hello")); var_dump(max(array(1,10, "hello"))); ?> produces: Content-Type: text/html string(5) "hello" int(1) int(10) string(5) "hello" that's because array_data_compare() (in basic_functions) is produces different results from is_smaller_function() (libzend) array_data_compare is the PHP 3 behaviour! so, what's the way to go: 1) use is_smaller_function() in array_data_compare() 2) create and array_data_compare_pval() and use that for min and max. way 2 would be 100% downward compatible but 1 would be the "right way" as is_smaller_function() is the function that the core language uses!I would go with 1). We should be consistent with the core language. I don't think it is important that we force backwards compatibility for non-standard use of these functions. Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/