Jump to content

[SOLVED] unset() is it worth it ?


benphelps

Recommended Posts

depends on where and how u r using it.

All variables are automatically unset after the script ends.

If you are overwriting and reusing variables and handle it efficiently then no need to unset, but if you referring them at many places and re-use or re-setting may cause confusion then unset() is safest..

 

As far as i know unset() will not slow down or fasten the speed as when u overwrite a variable it automatically gets unset first.

If you have a large variable that is no longer needed and your about to to set another large variable  then yes its worth it for the memory.. it really does depend on the script

but unsetting really to related to memory the cost of the CPU cycle to unset is normally worth the return in memory but if you have a single boolean variable it may not really be worth unsetting but if you have a image or large array then it is worth it..

 

Personally i only really unset the large variables, (of course their are exceptions)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.