background image

7:修改 php.ini
php.ini 如果找不到可以从 phpinfo()打出的信息看到
#cd /usr/local/php/lib/
php.ini 增加扩展信息
extension=caleng_module.so
 
8:重启 Apache
# /usr/local/apache2/bin/apachectl restart
 
9:检查加载
/usr/local/php/bin/php -m
 
10:PHP 调用

 

复制代码 代码如下:
 

echo

 a(1,2);

 

 

输出 3 就说明成功了!
=================================
下面是原文
Linux 下用 C 开发 PHP 扩展
一、首先下载 PHP 源码包,假设源码包目录为:/software/php-5.2.13 
一、首先下载 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)
string b(string str, int n)
2、通过扩展骨架生成器,将在 ext 目录下自动建立扩展目录 caleng_module
#> ./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
PHP_FUNCTION(a)
{
int x, y, z;