一、首先下载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) #> ./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
#> cd /software/php-5.2.13/ext/caleng_module #> /usr/localhost/webserver/php/bin/phpize #> ./configure --with-php-config=/usr/localhost/webserver/php/bin/php-config #> make #> make install 现在将在/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613目录下生成caleng_module.so文件 在php.ini配置文件中加入: extension=caleng_module.so. 搞定收工 |
|
来自: wwwijhyt图书馆 > 《程序设计》