How check memory location of variable in php?

前端 未结 6 1181
旧时难觅i
旧时难觅i 2020-12-06 10:05

How check memory location of variable in php?

Thanks

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 10:43

    If you need to know if $varA is a reference to $varB, then you're out of luck: the PHP innards does not present this information to the developer.

    However, you can extract some information about references by parsing the output from var_dump or debug_zval_dump(). Read the relevant manual sections, and see this question for some details.

    And have a ready of this (PDF) article by Derick Rethans on references in PHP.

    Watch out for the refcount when using debug_zval_dump() because the function always creates an additional reference within itself, incrementing the value by 1

提交回复
热议问题