Re: Default value if parameter is not passed in

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Thus wrote Quanah Gibson-Mount:
> Right now, I'm tweaking a function that has a bunch of optional parameters. 
> I would like to be able to set a default value for the very last one if it 
> is not passed in.  This essentially looks like:
> 
> 
> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ssl", &link, &arg1, 
> &arg1_len, &arg2, &arg2_len, &long, &long_len) == FAILURE { RETURN_FALSE; }
> 
> if (!long || long==NULL) {
>     long=DEFAULT_VALUE;
> }
> 
> However, what I found when printing out the value of "long" is that it has 
> been set to 1?!  I imagine this was by the zend_parse_parameters function. 
> Is there a way to disable it from setting values to optional parameters?

1. Read http://cvs.php.net/php-src/CODING_STANDARDS
2. Studying  source code on how current functions behave
3. ask questions like this in either internals@xxxxxxxxxxxxx or
   pecl@xxxxxxxxxxxxx


btw, the "l" flag expects long to be a long type, and it doesn't
assign the long_len variable.

HTH,

Curt
-- 
Quoth the Raven, "Nevermore."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux