gpt4 book ai didi

php - 取消设置对象数组是只取消设置数组还是取消所有对象?

转载 作者:行者123 更新时间:2023-12-04 14:29:50 24 4
gpt4 key购买 nike

我有一个对象数组。如果我调用 unset($array),它会取消设置数组和数组中的所有对象还是仅取消设置数组?让我们假设这些对象在其他任何地方都没有被引用。

最佳答案

如果该数组包含对该对象的唯一引用,则是。否则没有。另外,从 PHP 文档中要记住的事情:

unset() does just what it's name says - unset a variable. It does not force immediate memory freeing. PHP's garbage collector will do it when it see fits - by intention as soon, as those CPU cycles aren't needed anyway, or as late as before the script would run out of memory, whatever occurs first.

关于php - 取消设置对象数组是只取消设置数组还是取消所有对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2119301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com