做阵列()销毁所有previous值? [英] do array() destroy all previous values?

查看:97
本文介绍了做阵列()销毁所有previous值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个$阵列与存储在它的一些价值观。现在,如果我做的:

I have an $array with some values stored on it. Now, if I do :

$array=array();

所有的值/索引中删除?或者,我需要在它之前使用未设置()?

all values/index are deleted? Or I need to use unset() before it?

推荐答案

一个阵列正在与创建阵列(),这< STRONG>新数组对象赋给变量 $阵列

A new array is being created with array() and this new array object is assigned to the variable $array.

变量( $阵列)不再指向的原始的数组对象 - 因为PHP是一种垃圾回收的语言 - 的的原始的数组对象将有资格回收的如果(且仅当)的不再是强可从根对象。 (实际时间previous数组对象和对象包含它在实际删除取决于其他因素。)

The variable ($array) no longer points to the original array object -- and because PHP is a garbage collected language -- the original array object will be eligible for reclamation if (and only if) it is no longer strongly reachable from a root object. (The actual time the previous array object and objects it contained are actually deleted depends on other factors.)

快乐编码。

请参阅 PHP垃圾收集手册了解更多详细信息 - PHP使用混合GC(REF-计数和周期破)。

See PHP Garbage Collection Manual for more details -- PHP uses a hybrid GC (ref-count and cycle-breaking).

这篇关于做阵列()销毁所有previous值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆