永发信息网

如何编写一个独立的 PHP 扩展

答案:1  悬赏:30  手机版
解决时间 2021-02-25 23:38
  • 提问者网友:轻浮
  • 2021-02-25 19:58
如何编写一个独立的 PHP 扩展
最佳答案
  • 五星知识达人网友:孤独的牧羊人
  • 2021-02-25 21:28
一、首先下载PHP源码包,假设源码包目录为:/software/php-5.2.13
一、首先下载PHP源码包,假设源码包目录为:/software/php-5.2.13
#> cd /software/php-5.2.13/ext
二、假设我们要开发一个名为caleng_module的扩展,该扩展包含两个函数:a--处理两个整型相加和b-处理字符串重复输出;
1、首先编写一个函数定义文件,该文件编写函数原型后缀为def,假设为:caleng_module.def
int a(int x, int y)
string b(string str, int n)
2、通过扩展骨架生成器,将在ext目录下自动建立扩展目录caleng_module
#> ./ext_skel --extname=caleng_module --proto=caleng_module.def
3、修改配置文件: #> vim /software/php-5.2.13/ext/caleng_module/config.m4,将如下行的注释标签"dnl"去掉,修改后如下所示:
PHP_ARG_ENABLE(myfunctions, whether to enable myfunctions support,
Make sure that the comment is aligned:
[ --enable-myfunctions Enable myfunctions support])
4、完善函数a和b的功能: #> vim /software/php-5.2.13/ext/caleng_module/caleng_module.c
PHP_FUNCTION(a)
{
int x, y, z;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯