Re: something wrong with zend_parse_parameters_ex
| From: | Antony Dovgal | Date: | Fri, 07 Jul 2006 14:40:31 +0000 |
| Subject: | Re: something wrong with zend_parse_parameters_ex | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-3951@lists.php.net to get a copy of this message | ||
PHP is weakly typed, so such kind of check won't work.
If you really need to distinguish between LONG and STRING (I don't think you really do - _GET, _POST and friends contain only strings) just accept zval ("z") and check its type manually.
On 07.07.2006 18:33, Vanilla Hsu wrote:
Dear Sir: I try to use zend_parse_parameters_ex to get 2 kind of argument on the same function. here is my sample code. PHP_FUNCTION(vv_test) {-- Wbr, Antony Dovgalchar *str; int str_len; long val;if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET,ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == SUCCESS){ php_printf ("string: %s, %d", str, str_len); } else if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET,ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == SUCCESS){ php_printf ("int: %d", val); } else RETURN_NULL();} when I use <?php vv_test (123); ?> it will print "string: 123, 3"; even I use <?php vv_test (intval (123)); ?> it return the same result. Could someone check this for me? thanks.