PHP中unset销毁变量引发的问题
在php中我要销毁变量并内存释规范的写法就是直接使用unset()函数了,但是我们测试会发现unset只是当指向该值的所有变量(比如有引用变量指向该值)都被销毁后,地址才会被释放,下面我们来看几个实例。
首先我们来看一个例子:
代码如下 | 复制代码 |
$a = "hello springload"; |
这个我们很清楚,unset($b),只是断开了变量名和值得绑定,但是一个有意思的问题出现了:
代码如下 | 复制代码 |
$a = "hello springload"; |
为什么$a销毁了,为嘛$b的值还在呢?
注:unset()函数只有当指向该值的所有变量(比如有引用变量指向该值)都被销毁后,地址才会被释放,如下:
代码如下 | 复制代码 |
$a = "hello springload"; |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.