Re: Feature request for min() and max()
| From: | Andi Gutmans | Date: | Mon, 20 Nov 2000 16:43:02 +0000 |
| Subject: | Re: Feature request for min() and max() | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-38627@lists.php.net to get a copy of this message | ||
I agree with Sterling.
We should output an error because it's a wrong way to call it and you should make the person attentive to his mistake.
Please reverse this patch.
Andi
At 14:38 20/11/00 +0100, Sterling Hughes wrote:
At 08:31 AM 11/20/2000 -0500, Colin Viebrock wrote:--- Andi Gutmans <andi@zend.com> http://www.zend.com/[Mon, 20 Nov 2000] Andi Gutmans said:I didn't quite understand what this patch does. Can you explain on aPHP level? My *plan* was for this patch to change the behaviour of max() and min(), so that if you pass it one scalar value, instead of returning a "wrong number of arguments" warning, it just passes back the value of the scalar. So ... <? echo min(12); ?> Outputs "12", not an error. I'm not sure if my code is right though, thus my post to the list for someone else to take a quick look before committing it.I don't think that's a very good idea. If the user gives the min() function an invalid value, he should get an error. Anyway, the easiest way to this would simply be to change:if (zend_get_parameters_ex(1, &arr) == FAILURE || (*arr)->type != IS_ARRAY) { WRONG_PARAM_COUNT; }To:if (zend_get_parameters_ex(1, &arr) == FAILURE) { WRONG_PARAM_COUNT; }if ((*arr)->type != IS_ARRAY) { *return_value = **arr; zval_copy_ctor(return_value); return; }Adding an if .. else is really kind-of unneccessary. -Sterling