Implements an addition function, passing in 2 parameters, calculating the sum of the sums: 1. Create a new extension ./ext_skel --extname=hello 2.vi config.m4 Remove the following 3 lines at the beginning of the Dnl php_arg_ ENABLE (strive, whether to enable strive support, Make sure that the comment is aligned: [ --enable-strive enable strive support]) 3, write code  1.VI HELLO.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) { long num1,num2; if (Zend_parse_parameters (Zend_num_args () TSRMLS_CC, "ll", &num1, &num2 ) == failure) { return; } return_long (num1+ NUM2) }3. Add a function name to the array: const zend_function_entry hello_functions[] = { php_fe (addition, null) /* addition function */} explanation: The extension created here is called Hello, so you need to edit the hello.c file and add the corresponding function to it. The addition function is added here, the main function is to achieve the addition of two parameters. 2 parameters are defined, NUM1 and num2. zend_begin_arg_info : Start parameter block definition ZEND_END_ARG_INFO : End parameter Block definition ZEND_ARG_INFO : Declare common parameter php_function (addition) : Here is a specific function for the extension, the function is named (addition) The function defines two long variables, the variables defined here correspond to those defined in the above parameter block. return_long: Represents the return of a LONG type of value, 4. Compiling the installation extension, 5. Test addition function is available: php -r ' Echo addition (10,40); '
The integral parameter passing of PHP extended development