# alternative to $_GET or $_POST in PHP? Want to clear variables!



## r3drock3t88 (Jan 13, 2007)

Hey all,

I am asking for alternatives to the $_GET or $_POST because what I am trying to do requires the variable to be completely cleared after the page is refreshed. I have used "unset($_GET['var']), but I found that it does not actually clear it?

Is there a way to actually clear the variable besides altering the URL itself? Or an alternative to $_GET? Or a way to actually clear the variables?!

Thanks in advance!!!!


----------



## MMJ (Oct 15, 2006)

foreach loop.

http://php.net/foreach


----------



## r3drock3t88 (Jan 13, 2007)

Hello MMJ,

Thank you very much for a response! However, I am very new to PHP and still learning, would you mind explaining a little bit more on how you would go about using such a loop? I read the php.net article on it and understand what it is for, but I guess what I am asking is how is it an alternative to $_GET or $_POST ???

Thank you again!


----------



## MMJ (Oct 15, 2006)

Not really, you can use some variables in the $_SERVER array which might contain the URL (with GET variables).

a foreach loop is to clear GET and POST like you asked.


----------



## Big-K (Nov 22, 2003)

unsetting a variable only works for that specific execution of the script. Every time a script is run, the $_GET array is filled via the url. If you want a page to have something in the url that won't be in the $_GET array, you'll have to manually remove it yourself in each execution of the script.


----------

