Hi Vinicius On Mon, Mar 10, 2025 at 5:15 PM Vinicius Dias <carlosv...@gmail.com> wrote: > > > TL;DR: Does setting a variable to `null` (or even `unset`ing it) have > > **any** effect if that's the last instruction of a function?
As others have pointed out, it is _almost_ completely unobservable. There are two small differences: 1. When the variable is a reference, $var = null; will write null to the reference, rather than the variable. The "out of scope cleanup" would be closer to an unset() rather than = null. 2. = null / unset() runs destructors in the scope of the child, while the cleanup on function exit executes in the parent scope. https://3v4l.org/obAgg But in terms of garbage collection, there's no value that would be cleaned up with an explicit unset() that wouldn't also be cleaned up when leaving the function. The arguments from your co-workers seem to rely on a faulty understanding of the engine. Ilija