Skip to content

Instantly share code, notes, and snippets.

@abiusx
Created April 25, 2016 16:23
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 abiusx/ad83a02125c120367a75e0027a324c67 to your computer and use it in GitHub Desktop.
Save abiusx/ad83a02125c120367a75e0027a324c67 to your computer and use it in GitHub Desktop.
An implementation of is_ref for PHP in C (for extensions)
ZEND_BEGIN_ARG_INFO_EX(phpx_byref_arginfo,
1 /*pass_rest_by_reference*/,
0/*return_reference*/,
1/*required_num_args*/)
ZEND_ARG_PASS_INFO(1/*by_ref*/)
ZEND_END_ARG_INFO();
PHP_FUNCTION(is_ref)
{
zval *z;
int res;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,"z",&z)==FAILURE)
return;
RETURN_BOOL(Z_REFCOUNT_P(z) > 2);
//1 is the reference sent to this function, the other is the actual var.
//if more, reference!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment