Deleting all variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Deleting all variables

Post by Bennettman »

Is there a way in PHP to delete every variable on the page without typing out each variable unset($var1,$var2,etc) style?
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

Not really, if you are using globals though, a bit drastic but you could:

Code: Select all

unset($GLOBALS);
But that would mean every single variable you create needs to be in the global scope.

I would suggest you ditch variables in favour of array's in this instance, at least then you only have to worry about a single variable (array), could be hard to program though.

Regards,
Post Reply