Linux环境用C编写PHP扩展

编写从一个helloworld开始

1:先去网上下载php源码

2:下载来后解压,进入ext目录

3:利用ext_skel

./ext_skel --extname=hellowworld

4:进行hellowworld目录,修改config.m4文件,注释掉(注释,实际上也就是去掉前面的dnl)

PHP_ARG_ENABLE(myfunctions, whether to enable myfunctions support,
Make sure that the comment is aligned:
[  --enable-myfunctions           Enable myfunctions support])

5:用phpisze来创建

/usr/local/php/bin/phpisze

 ./configure --with-php-config=/usr/local/php/bin/php-config

make

会报错,undefined PHP_FE_END

搞不清楚状态,总之编辑hellowworld.c,将PHP_FE_END修改为

{NULL,NULL,NULL}

然后重新

make&&make install

成功编译,新编译得模块在

/usr/local/php/lib/extensions/no-debug-non-zts-20060613 目录下

然后编辑php.ini,加入该模块

extension=hellowworld.so

重新apache,然后写一个页面

<?php
 echo phpinfo();

查看一下,是否存在hellowworld模块,

本次非常简单,生成了hellowword拓展,但是该扩展并没有任何函数,如果需要写函数,请参考其他文档,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值