14.7.1. A Simple Example
The following code gets a long (all integers in PHP are longs), a
string, and an optional double (all floating-point values in PHP are
double-precision):
long l;
char *s;
int s_len;
double d = 0.0;
if (zend_parse_parameters(ZEND_NUM_ARGS( ) TSRMLS_CC, "ls|d", &l, &s, &s_len)
== FAILURE) return;
From a PHP script, this function might be called like this:
$num = 10; $desc = 'This is a test'; $price = 69.95;
add_item($num, $desc); // without the optional third argument
add_item($num, $desc, $price); // with the optional third argument
This results in long l being
set to 10, char *s containing
the string "This is a Test", and
s_len being set to 14. For the first call,
double d maintains the default
0.0 value that you set, but in the second call, where the user
provides an argument, it is set to 69.95.