如何在php扩展开发中调用`callable` zval?

时间:2012-09-23 15:28:26

标签: c php-extension

如果zval是可调用对象,我该如何在扩展名c代码中运行它?

或如何将zval转换为zend_fcall_info

1 个答案:

答案 0 :(得分:1)

搜索zend_is_callable并深入了解php src代码后,我知道如何调用可调用的zval:

zval ret;

zval* params[] = { param }; // param is zval* too

if (SUCCESS == call_user_function(CG(function_table), NULL, callable, &retval, 1, params TSRMLS_CC)) {
    // callable is a zval*
    // you can do something with the retval now
}