1

I followed the steps mentioned at Passing a variable by reference into a PHP extension for Passing a variable by reference into a PHP extension. This is working fine for PHP 5 but when I try the same in Php7 and its not working. Any suggestions? Here is my code snippet.

ZEND_BEGIN_ARG_INFO(params_ref_arg_arginfo, 0) 
  ZEND_ARG_INFO(1, a)
ZEND_END_ARG_INFO()

PHP_FUNCTION(sample_byref_compiletime)
{
    zval *a;     
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a ) == FAILURE)
    {
        php_printf("Error");
        RETURN_NULL();
    }         
    zval_dtor(a);   
    ZVAL_LONG(a, 40);
}

  PHP_FE(sample_byref_compiletime, params_ref_arg_arginfo)

Thank you for the help.

Community
  • 1
  • 1
Radha
  • 13
  • 2

1 Answers1

0

Change from "z" to "z/". View details in https://wiki.php.net/phpng-upgrading. Possible type specifiers http://php.net/manual/en/internals2.funcs.php.

Also you can change your code to:

PHP_FUNCTION(sample_byref_compiletime)
{
    zval *a;     
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
        "z", &a ) == FAILURE)
    {
        php_printf("Error");
        RETURN_NULL();
    }
    ZVAL_DEREF(a);
    SEPARATE_ZVAL_NOREF(a);
    zval_dtor(a);   
    ZVAL_LONG(a, 40);
}