1,创建新的扩展
./ext_skel --extname=fcall
2,代码
typedef struct _zend_fcall_info {
size_t size;
HashTable *function_table;
zval *function_name;
HashTable *symbol_table;
zval **retval_ptr_ptr;
zend_uint param_count;
zval ***params;
zval *object_ptr;
zend_bool no_separation;
} zend_fcall_info;
typedef struct _zend_fcall_info_cache {
zend_bool initialized;
zend_function *function_handler;
zend_class_entry *calling_scope;
zend_class_entry *called_scope;
zval *object_ptr;
} zend_fcall_info_cache;
zend_fcall_info finfo;
zend_fcall_info_cache fcache;
char *name = NULL;
zval **params[1];
zval *arg, *retval = NULL;
zend_fcall_info_init(&fname, IS_CALLABLE_STRICT, &finfo, &fcache, &name, NULL TSRMLS_CC); //初始化fcall_info
/*填充参数*/
MAKE_STD_ZVAL(arg);
ZVAL_STRING(arg, "Hello World", 1);
params[0] = &arg;
finfo.param_count = 1; //参数数量
finfo.params = params; //参数
finfo.retval_ptr_ptr = &retval; //返回值
/*执行函数*/
zend_call_function(&finfo, &fcache TSRMLS_CC)