下面的c代码为php7引用计数会发生什么? 在PHP7 zval
s的栈上创建的,所以引用问题就出来了:php7 zend扩展:refcount为堆栈变量?
zval destination;
array_init(destination);
{
// scope begin
zval val;
// does val's refcount incremented here or val is copied?
add_next_index_zval(destination, val);
// here the "val" will be destroyed.
// Does "destination" will experience any problems?
}
很难说没有更具体的代码,但通常这是好的。 val的值被复制到数组中,所以如果'val'变量超出范围就无关紧要了。 – NikiC