Re: Advice wanted on function arguments
| From: | Markus Fischer | Date: | Sat, 05 Jan 2002 20:48:07 +0000 |
| Subject: | Re: Advice wanted on function arguments | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-75971@lists.php.net to get a copy of this message | ||
On Sat, Jan 05, 2002 at 02:10:17PM -0600, Brian Foddy wrote :
> 2. Overload the function arguments and check which type of arg is being
> passed.
Just accept a ZVAL and do your appropriate conversion later
on.
>
> Questions...
> 2. How difficult / successful is it to test the arg type for solution 2.
It's a matter of
switch(Z_TYPE_P(zval_container)) {
case IS_STRING:
// do appropriate conversion
break;
case IS_LONG:
// everythings fine
break;
default:
php_error(E_WARNING, "%s(): argument 1 must be integer or string",
get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
IMHO. Watch out, YMMV; HTH.
--
Please always Cc to me when replying to me on the lists.