首先进入PHP源代码目录中的ext目录,执行如下命令:
# ./ext_skel --extname=自定义模块名
执行完成后,会生成以“自定义模块名”命名的文件夹,进入这个文件夹后编辑config.m4文件
找到如下代码:
dnl PHP_ARG_WITH(Test, for Test support,
dnl Make sure that the comment is aligned:
dnl [ --with-Test Include Test support])
或者
dnl PHP_ARG_ENABLE(Test, whether to enable Test support,
dnl Make sure that the comment is aligned:
dnl [ --enable-Test Enable Test support])
去掉每行前面的dnl
如果是想通过动态引用,建议使用--enable-Test
三、编写调用函数
编辑Test.c文件,找到如下代码:
zend_function_entry Test_functions[] = {
PHP_FE(confirm_Test_compiled, NULL) /* For testing, remove later. */
PHP_FE(test, NULL) /* 增加这一行,其中test代表在PHP文件中的函数调用名 */
{NULL, NULL, NULL} /* Must be the last line in Test_functions[] */
};