PHP调用C函数简单例子

本文介绍了如何在PHP中调用C函数,通过使用PHP扩展开发工具ext_skel创建名为helloworld的扩展目录,修改config.m4和php_helloworld.c文件来定义和实现函数。详细步骤包括配置、编译和安装过程,以及如何在PHP脚本中调用自定义的扩展函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、找到PHP扩展脚本ext_skel,ext_skel是PHP源代码中的脚本工具,位于目录ext下

find / -name ext_skel

2、 生成名字为helloworld的目录,该目录包含所需的文件

./ext_skel --extname=helloworld
# cd helloworld/
# ls
config.m4  config.w32  CREDITS  EXPERIMENTAL  helloworld.c  
helloworld.php  php_helloworld.h  tests

3、修改config.m4

//修改
dnl PHP_ARG_WITH(helloworld, for helloworld support,
dnl Make sure that the comment is aligned:
dnl [  --with-helloworld             Include helloworld support])

//为
PHP_ARG_WITH(helloworld, for helloworld support,
[  --with-helloworld             Include helloworld suppo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值