Skip to content

Instantly share code, notes, and snippets.

@Sean-Der
Created May 20, 2015 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sean-Der/1be1c8b998d95ef51bee to your computer and use it in GitHub Desktop.
Save Sean-Der/1be1c8b998d95ef51bee to your computer and use it in GitHub Desktop.
//PHP 5 Code
zval *foobar, *foobar2;
ALLOC_INIT_ZVAL(foobar)
ALLOC_INIT_ZVAL(foobar2)
array_init(foobar);
array_init(foobar2);
Z_SET_ISREF_P(foobar);
fprintf(stdout, "%d \n", Z_REFCOUNT_P(foobar));
add_next_index_zval(foobar2, foobar);
ZVAL_COPY_VALUE(return_value, foobar2);
//PHP 5 output
1
array(1) {
[0]=>
&array(0) {
}
}
//PHP 7 Code
zval foobar, foobar2;
array_init(&foobar);
array_init(&foobar2);
ZVAL_MAKE_REF(&foobar);
fprintf(stdout, "%d \n", Z_REFCOUNT_P(&foobar));
add_next_index_zval(&foobar2, &foobar);
ZVAL_COPY_VALUE(return_value, &foobar2);
//PHP 7 Output
1
array(1) {
[0]=>
array(0) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment