Jump to content

unset question


Liquid Fire

Recommended Posts

No. unset destroys the variable. defining it as null maintains the variables existence.

 

Though I don't think it makes a difference beyond memory consumption. Most functions that check if a variables exists (isset(), empty() ect..) will return the same whether null or unset() is used.

 

The memory difference between

unset($var);

and

$var = null;

 

is incredibly minimal, and i wouldn't be too concerned unless you're doing something on an utterly massive scale

Link to comment
https://forums.phpfreaks.com/topic/95631-unset-question/#findComment-489594
Share on other sites

No. unset destroys the variable. defining it as null maintains the variables existence.

 

Though I don't think it makes a difference beyond memory consumption. Most functions that check if a variables exists (isset(), empty() ect..) will return the same whether null or unset() is used.

 

The memory difference between

unset($var);

and

$var = null;

 

is incredibly minimal, and i wouldn't be too concerned unless you're doing something on an utterly massive scale

 

Well this is for a framework i am building so i guess i will use the unset instead if = null or = array() or etc...

Link to comment
https://forums.phpfreaks.com/topic/95631-unset-question/#findComment-489668
Share on other sites

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.