Tag Archives: php functions

The Better Way to Unset Variables in PHP

Don’t know why, but most of times I see the PHP unset() multilined with a only one parameter!?

unset($var1);
unset($var2);
unset($var3);

But as you can see from the PHP doc page of unset() this method takes optional parameter count.

void unset(mixed $var [, mixed $var [, mixed $...]])

So perhaps a better solution can be:

unset($var1, $var2, $var3);

It’s at least single lined!