Optional long and string:
long opt_l = 0;
char *opt_str = NULL;
long opt_str_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"|ls", &opt_l, &opt_str, &opt_str_len) == FAILURE) {
Get the first two parameters as resource and optional boolean:
zval *resource;
zend_bool b = FALSE;
if (zend_parse_parameters(2 TSRMLS_CC, "r|b", &resource, &b) == FAILURE) {
Get a long or a string:
long number;
char *str;
int str_len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
"l", &number) == SUCCESS) {
/ Do something with the number /
} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
"s", &str, &str_len) == SUCCESS) {
/ Do something with the string /
} else {
/ Output error /
}