我应该在php __destruct()中使用unset吗? [英] Should I use unset in php __destruct()?

查看:67
本文介绍了我应该在php __destruct()中使用unset吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

取消设置您在类中使用的变量是一种好习惯吗?还是可选的?

Is it a good practice to unset the variables that you used in a class? Or its an optional?

如果是一种好的做法,那么使用unset函数的好处是什么?

If its a good practice what is the benefit of using the unset function?

推荐答案

您真的不需要担心清理PHP中的变量声明,它的垃圾回收会为您处理所有这些事情.您的__destruct()方法主要用于关闭持久连接.

You really don't need to worry about cleaning up your variable declarations in PHP, its garbage collection takes care of all of that for you. Your __destruct() methods are primarily for things like closing persistent connections.

这篇关于我应该在php __destruct()中使用unset吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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