PHP_FUNCTION(confirm_laiwenhui_compiled);
/* For testing, remove later. */
PHP_FUNCTION(test);
然后
vim laiwenhui.c
在 PHP_FE(confirm_laiwenhui_compiled, NULL)
后面添加 PHP_FE(test, NULL)
添加后为:
代码如下:
zend_function_entry laiwenhui_functions[] = {
PHP_FE(confirm_laiwenhui_compiled, NULL)
/* For testing, remove later. */
PHP_FE(test, NULL)
/* For testing, remove later. */
{NULL, NULL, NULL}
/* Must be the last line in laiwenhui_functions[] */
};
在文件最后面增加如下代码:
代码如下:
PHP_FUNCTION(test)
{
char *arg = “This my first extention!”;
int len;
char *strg;
len = spprintf(&strg, 0, “%s\n”, arg);
RETURN_STRINGL(strg, len, 0);
}
第四步:编译代码
代码如下:
cd php-5.2.6/ext/laiwenhui
/opt/module/php/bin/phpize
./configure –with-php-config=/opt/module/php/bin/php-config
make
make install
我的 PHP 安装路径为:/opt/module/php
这个时候会生成一个文件 /opt/module/php/lib/php/extensions/no-debug-non-zts-
20060613/laiwenhui.so
编辑 PHP 配置文件 php.ini
,添加扩展: