Unexpected observation: var_dump() of an array is flagging referenced elements… since when?

后端 未结 1 1718
春和景丽
春和景丽 2021-01-02 18:41

I\'ve just been running some simple debug tests against arrays, and noticed that when I do a var_dump() of an array, the output is flagging any element in the array that is

相关标签:
1条回答
  • 2021-01-02 18:43

    Not sure if this answers your question, but you can use

    debug_zval_dump($array);
    

    to get the refcount:

    array(4) refcount(2){ 
        [0]=> long(1) refcount(1) 
        [1]=> &long(2) refcount(2) 
        [2]=> long(3) refcount(1) 
        [3]=> &long(4) refcount(2) 
    } 
    

    Also see this Article by Derick Rethans (PHP Core Dev) about Refcounting.

    0 讨论(0)
提交回复
热议问题