array and call_user_function
| From: | mr esnafrao | Date: | Mon, 08 Sep 2008 16:58:19 +0000 |
| Subject: | array and call_user_function | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-40348@lists.php.net to get a copy of this message | ||
Hi all,
I'm having problems passing an array to the function call_user_function as
parameter. This is the code:
zval *args[3], *func, *retval;
MAKE_STD_ZVAL(func);
MAKE_STD_ZVAL(retval);
MAKE_STD_ZVAL(args[0]);
MAKE_STD_ZVAL(args[1]);
MAKE_STD_ZVAL(args[2]);
ALLOC_HASHTABLE(args[2]);
// creates hash and fills
zend_hash_init(args[2], 0, NULL, NULL, 0);
g_hash_table_iter_init (&iter, m->params);
while (g_hash_table_iter_next (&iter, &key, &value)) {
zend_hash_add(args[2], key, strlen(key), value, strlen(value),
NULL);
}
ZVAL_STRING(args[0], estrdup(m->sender), 0);
ZVAL_STRING(args[1], estrdup(m->cmd), 0);
ZVAL_STRING(func, estrdup(handler), 0);
if (call_user_function(EG(function_table),
NULL,
func,
retval, 3,
args TSRMLS_CC) == FAILURE) {
g_debug("error calling method: %s", handler);
}
zval_dtor(retval);
zval_dtor(func);
zval_dtor(args[0]);
zval_dtor(args[1]);
zend_hash_destroy(args[2]);
FREE_HASHTABLE(args[2]);
I suppose that the problem is the conversion between the Hash and the zval,
but I don't know how to do it.
Thanks in advance :)
regards