Click to See Complete Forum and Search --> : How do I empty or unset a variable ?


jeddik
11-27-2006, 03:14 AM
Hello

I have this if statement:

if(!isset($dot1)){$dot = "575px";}

It is picking up that $dot1 has got a variable. After using the variable
how do I empty it - do I use an unset stmt or set it to null ?

Thanks.

theRamones
11-27-2006, 03:46 AM
Both right.

Completely way to unset variables :
1. unset($var) or
2. $var = false or $var = "false" or
3. $var = "" or
4. $var = 0 or
4. $var = null or

especially for unset() this proc are destroys the specified variables

jeddik
11-27-2006, 03:50 AM
thanks :)

jeddik
11-27-2006, 03:56 AM
BTW do I need to do ths:

unset($dot1);
unset($dot2);
unset($dot3);

or can I do:

unset($dot1, $dot2, $dot3);

????

theRamones
11-27-2006, 04:01 AM
The second way are more effective,
unset($dot1, $dot2, $dot3);

jeddik
11-27-2006, 04:10 AM
yer thats what I thought :)

Keep up the good advice !

bokeh
11-27-2006, 04:48 AM
The only way to unset a variable is with unset(). All the other examples will return true when tested with isset().