php扩展 call_user_function,PHP扩展里通过 call_user_function_ex 调用用户空间函数
发布日期:2021-10-26 17:40:48 浏览次数:1 分类:技术文章

本文共 1850 字,大约阅读时间需要 6 分钟。

最近在看YAF的源码,其中可能我认为最关键的应该是在PHP扩展里怎么调用用户空间里的函数了!对于一个framework来说,最基本的功能就是路由到请求对应的Action了。

在PHP扩展里是通过 call_user_function_ex 函数来调用用户空间的函数的。下面我们来分析下这个函数的使用方式吧。

下面这个是call_user_function_ex 函数的定义:

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.

CG(function_table)

object_ppis a pointer to a zval pointer where an initialized object is located. If you use this, set function_table to NULL, as previously noted.

function_name is a pointer to a zval which contains the name of the function in string form.

retval_ptr_ptr is a pointer to a zval pointer which will contain the return value of the function. The zval passed doesn\'t need to be initialized, and it may cause problems if you initialize it when it\'s not neccesary. You

must

always pass a real pointer to a zval pointer, you may not use NULL for this as it will cause a segmentation fault.

param_count is the number of parameters you wish to pass to the function being called.

params is an array of pointers to zval pointers. Note: this is _not_ a PHP/zval array, it is a C array. Example:

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.

symbol_table is the hash table for symbols. I currently don\'t know what this is, so when I find out, I\'ll edit the post and put it here

After the symbol_table parameter, you should put TSRMLS_CC to make it threadsafe.

c7d891e87903ab9e05a0eb4b18dc5c04.png

8330628bf0d454946efd9191f8aafd43.png

转载地址:https://blog.csdn.net/weixin_33952775/article/details/115987384 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:matlab数据导入 spss,【excel数据导入系统】excel数据导入_excel数据导入spss-系统城...
下一篇:numpy和matlab用法对比,Numpy | 与Matlab科学计算对比

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2024年03月29日 05时36分14秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

怎么查看elementui版本_2021新年 Vue3.0 + Element UI 尝鲜小记 2019-04-21
adreno630gpu参数_小米8搭载Adreno 630图形处理器 比荣耀play上的GPU Turbo更成熟 2019-04-21
带bitlocker解密的pe_如何在PE下解锁bitlocker 2019-04-21
lj245a引脚功能图_谁找到74254,74LS245芯片引脚的功能和功能图啊? 2019-04-21
sts 创建webservice项目_通过eclipse将Java生成webservice | 学步园 2019-04-21
python数字字符串和数字相加_数字和字符串 2019-04-21
python风控模型举例_一文搞定风控模型6大核心指标(附代码) 2019-04-21
java arraylist 写入文件_java-将自定义对象的ArrayList写入文件 2019-04-21
ice glacier2 java_ICE提纲之demo/Glacier2/callback(跨网回调) 2019-04-21
java 转发上传文件_java 后台请求其他接口转发文件 2019-04-21
Java get set 同步_java – getResultSet()“每个结果只能调用一次” 2019-04-21
java jmx 配置_为什么在配置JMX时Java打开3个端口? 2019-04-21
java thread回调_使用Runnable在Java中实现回调 2019-04-21
java 内存区_Java内存模型和Java内存区域的区别和联系? 2019-04-21
java定时任务监控_Spring定时任务使用及如何使用邮件监控服务器 2019-04-21
java crc32 使用_Java CRC32的用法 2019-04-21
java读取unicode_java怎么样将unicode解码读取?Java读取本地文件进 2019-04-21
java.io.file()_Java File getUsableSpace()方法 2019-04-21
java httpclient 工具_spring整合httpClient工具类 2019-04-21
java监控其他服务器运行状态_windows服务器监控多个tomcat运行状态 2019-04-21