实现一个加法函数,传入2个参数,计算相加的和:1.创建一个新的扩展./ext_skel--extname=hello2.viconfig.m4去掉以下3行行首的dnlPHP_ARG_ENABLE(hello,whethertoenablestrivesupport,Makesurethatthecommentisaligned:[--enable-helloEnablestrivesupport])3,编写代码1.vihello.c2.#添加下面的代码ZEND_BEGIN_ARG_INFO(addition_arginfo,0)ZEND_ARG_INFO(0,num1)ZEND_ARG_INFO(0,num2)ZEND_END_ARG_INFO()PHP_FUNCTION(addition){longnum1,num2;if(zend_parse_parameters(ZEND_NUM_ARGS()TSRMLS_CC,"ll",&num1,&num2)==FAILURE){return;}RETURN_LONG(num1+num2);}3.在数组中添加函数名:constzend_function_entryhello_functions[]={PHP_FE(addition,NULL)/*additionfunction*/}解释:这里创建的拓展名为hello,所以需要编辑hello.c文件,在里面加上相应的函数。这里加上了addition函数,主要功能是实现两个参数的相加。定义了2个参数,num1与num2。ZEND_BEGIN_ARG_INFO:开始参数块定义ZEND_END_ARG_INFO:结束参数块定义ZEND_ARG_INFO:声明普通参数PHP_FUNCTION(addition):这里是为扩展添加具体的函数,函数名为(addition)函数内定义了两个long类型的变量,这里定义的变量与上面参数块中定义的对应。RETURN_LONG:表示返回一个long类型的值,4.编译安装扩展,phpize./configure--with-php-config=php_conf_dirmake&&makeinstallviphp.iniextension=strive.soreloadphp-fpm5.测试addition函数是否可用:php-r'echoaddition(10,40);'