linux下 C语言对 php 扩展
linux  /  管理员 发布于 4年前   270
三,更改配置和程序 根据你自己的选择将 dnl PHP_ARG_WITH(my_ext, for my_ext support, dnl [ --with-my_ext Include my_ext support]) PHP_ARG_WITH(my_ext, for my_ext support, [ --with-my_ext Include my_ext support]) dnl PHP_ARG_ENABLE(my_ext, whether to enable my_ext support, dnl [ --enable-my_ext Enable my_ext support]) PHP_ARG_ENABLE(my_ext, whether to enable my_ext support, Make sure that the comment is aligned: $ vi ext/my_ext/php_my_ext.h 将 将 在最后添加: 四,编译 这时会编译出 my_ext/modules/my_ext.so 五,配置php.ini $ vi php.ini 六,测试 $ /usr/local/php/bin/php test.php 则大功告成 ps:如有问题请留言,大家共同探讨
下载php 5.2.6 源码 并解压
编译安装,搭建php环境
二,创建扩展项目
进入源码目录
cd php5.2.6/ext/
./ext_skel --extname=my_ext
创建名字为my_ext的项目,最终会生成my_ext.so
dnl Make sure that the comment is aligned:
修改成
Make sure that the comment is aligned:
或者将
dnl Make sure that the comment is aligned:
修改成
[ --enable-my_ext Enable my_ext support])
PHP_FUNCTION(confirm_my_ext_compiled); /* For testing, remove later. */
更改为
PHP_FUNCTION(say_hello);
$ vi ext/my_ext/my_ext.c
zend_function_entry php5cpp_functions[] = {
PHP_FE(confirm_my_ext_compiled, NULL) /* For testing, remove later. */
{NULL, NULL, NULL} /* Must be the last line in php5cpp_functions[] */
};
更改为
zend_function_entry php5cpp_functions[] = {
PHP_FE(say_hello, NULL)
{NULL, NULL, NULL} /* Must be the last line in php5cpp_functions[] */
};
PHP_FUNCTION(say_hello)
{
zend_printf("hello world\n");
}
$ cd my_ext
$ /usr/local/php/bin/phpize
ps: 如果出现:Cannot find autoconf.……的错误信息,则需要安装 autoconf (安装过程略)
$ ./configure --with-php-config=/usr/local/php/bin/php-config
$ make
将my_ext.so放入/usr/local/php/ext/目录
修改添加如下:
extension_dir = '/usr/local/php/ext/'
extension=my_ext.so
$ vi test.php
say_hello();
?>
hello world.您可能感兴趣的文章:
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号