环境:PHP 5.2.14 CentOS 5.5
第一步:建立扩展骨架
cd php-5.2.14/ext
./ext_skel –extname=laiwenhui
第二步:修改编译参数
cd php-5.2.14/ext/laiwenhui
vi config.m4
去掉
PHP_ARG_ENABLE(laiwenhui, whether to enable laiwenhui support,
[ --enable-laiwenhui Enable laiwenhui support])
两行前面的dnl
修改后为:
复制代码 代码如下:
dnl Otherwise use enable:
PHP_ARG_ENABLE(laiwenhui, whether to enable laiwenhui support,
dnl Make sure that the comment is aligned:
[ --enable-laiwenhui Enable laiwenhui support])
复制代码 代码如下:
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