So I decided to write an extension for php. Everything seems to be fine except I\'m stuck on a tiny problem.
I have php-5.4.9
source codes. There is file
The easiest way to figure out how a function works is to search for it on lxr.php.net. The first example that turns up is in readline: http://lxr.php.net/xref/PHP_TRUNK/ext/readline/readline.c#474
The use for mail
is analogous. Given the arguments as zvals (to_zval
, from_zval
, msg_zval
) the call is very simple:
zval *params = { to_zval, from_zval, msg_zval };
zend_uint param_count = 3;
zval *retval_ptr;
zval function_name;
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "mail", 1);
if (call_user_function(
CG(function_table), NULL /* no object */, &function_name,
retval_ptr, param_count, params TSRMLS_CC
) == SUCCESS
) {
/* do something with retval_ptr here if you like */
}
/* don't forget to free the zvals */
zval_ptr_dtor(&retval_ptr);
zval_dtor(&function_name);
If you don't have the parameters as zvals already, then you can create them using MAKE_STD_ZVAL
and ZVAL_STRING
.