The integral parameter passing of PHP extended development

Source: Internet
Author: User

  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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.