最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

linux下 C語言對 php 擴展

 更新時間:2008年12月14日 17:57:40   作者:  
linux C語言對 php 擴展的設(shè)置技巧
一,搭建php環(huán)境
下載php 5.2.6 源碼 并解壓
編譯安裝,搭建php環(huán)境

二,創(chuàng)建擴展項目

進入源碼目錄
cd php5.2.6/ext/
./ext_skel --extname=my_ext
創(chuàng)建名字為my_ext的項目,最終會生成my_ext.so

三,更改配置和程序
$ vi ext/my_ext/config.m4

根據(jù)你自己的選擇將

dnl PHP_ARG_WITH(my_ext, for my_ext support,
dnl Make sure that the comment is aligned:

dnl [  --with-my_ext             Include my_ext support])
修改成

PHP_ARG_WITH(my_ext, for my_ext support,
Make sure that the comment is aligned:

[  --with-my_ext             Include my_ext support])
或者將

dnl PHP_ARG_ENABLE(my_ext, whether to enable my_ext support,
dnl Make sure that the comment is aligned:

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:
[  --enable-my_ext           Enable my_ext support])

$ vi ext/my_ext/php_my_ext.h


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: 如果出現(xiàn):Cannot find autoconf.……的錯誤信息,則需要安裝 autoconf (安裝過程略)
$ ./configure  --with-php-config=/usr/local/php/bin/php-config
$ make

這時會編譯出 my_ext/modules/my_ext.so

五,配置php.ini
將my_ext.so放入/usr/local/php/ext/目錄

$ vi php.ini

修改添加如下:
extension_dir = '/usr/local/php/ext/'
extension=my_ext.so  

六,測試
$ vi test.php
<?php
   say_hello();
?>

$ /usr/local/php/bin/php test.php
hello world.

則大功告成

ps:如有問題請留言,大家共同探討

相關(guān)文章

最新評論

玛沁县| 宝丰县| 宁陵县| 灵石县| 天峻县| 香格里拉县| 肃南| 芮城县| 永泰县| 江北区| 师宗县| 南雄市| 平潭县| 朝阳县| 堆龙德庆县| 开化县| 如皋市| 呼图壁县| 五指山市| 浮山县| 张掖市| 来凤县| 巴林右旗| 蓝田县| 资兴市| 方城县| 大城县| 德保县| 安新县| 宜章县| 类乌齐县| 衡水市| 巴彦县| 合阳县| 收藏| 宣汉县| 子长县| 博客| 安义县| 华亭县| 白水县|