如何修改PHP脚本扩展,探讨:如何编写PHP扩展

//(依赖外部库)

dnl PHP_ARG_WITH(myext, for myext support,

dnl Make sure that the comment is aligned:

dnl [ --with-myext Include myext support])

//去掉dnl

PHP_ARG_WITH(myext, for myext support,

Make sure that the comment is aligned:

[  --with-myext             Include myext support])

//或者将 //(不依赖外部库) dnl PHP_ARG_ENABLE(myext, whether to enable myext support,dnl Make sure that the comment is aligned:dnl [ --enable-myext Enable myext support])//去掉dnl

修改头文件php_myext.h:

//PHP_FUNCTION(confirm_myext_compiled); /* For testing, remove later. */

//修改为

PHP_FUNCTION(myext); /* For testing, remove later. */

修改myext.c:

//将

//zend_function_entry myext_functions[] = {

// PHP_FE(confirm_myext_compiled, NULL) /* For testing, remove later. */

// {NULL, NULL, NULL} /* Must be the last line in myext_functions[] */

//};

//修改为

zend_function_entry myext_functions[] = {

PHP_FE(myext, NULL) /* For testing, remove later. */

{NULL, NULL, NULL} /* Must be the last line in myext_functions[] */

};

//在文件底部添加自己的函数

PHP_FUNCTION(myext)

{

zend_printf("Hello World!\n");

}

安装自己的php扩展myext:

/usr/local/php/bin/phpize

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

make

make install

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值