What's better at freeing memory with PHP: unset() or $var = null

前端 未结 13 2161
陌清茗
陌清茗 2020-11-22 08:57

I realise the second one avoids the overhead of a function call (update, is actually a language construct), but it would be interesting to know if one is be

13条回答
  •  悲&欢浪女
    2020-11-22 09:31

    unset is not actually a function, but a language construct. It is no more a function call than a return or an include.

    Aside from performance issues, using unset makes your code's intent much clearer.

提交回复
热议问题