最近在看YAF的源码,其中可能我认为最关键的应该是在PHP扩展里怎么调用用户空间里的函数了!对于一个framework来讲,最基本的功能就是路由到请求对应的Action了。 php
在PHP扩展里是经过 call_user_function_ex 函数来调用用户空间的函数的。下面咱们来分析下这个函数的使用方式吧。 函数
下面这个是call_user_function_ex 函数的定义: post
ZEND_API int call_user_function_ex( HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, zend_uint param_count, zval **params[], int no_seperation, HashTable *symbol_table TSRMLS_DC);
function_table is the hash table where the function you wish to call is located. If you\'re using object_pp, set this to NULL. If the function is global, most likely it\'s located in the hash table returned by the macro CG() with the parameter `function_table\', i.e. ui
CG(function_table)object_pp is a pointer to a zval pointer where an initialized object is located. If you use this, set function_table to NULL, as previously noted.
zval *foo; zval *bar; zval **params[2]; params[0] = &foo; params[1] = bar;no_seperation is either 1 or 0, 0 being no zval seperation, 1 enabling zval seperation.
http://forums.phpfreaks.com/topic/1303-call-user-function-ex-documentation/ this