I need to set the $_GET values; can I do this?
ie I have an empty $_GET array. How can make it nonempty with php?
Maybe with help of http headers?
Thank you in advance;
I need to set the $_GET values; can I do this?
ie I have an empty $_GET array. How can make it nonempty with php?
Maybe with help of http headers?
Thank you in advance;
The
$_GET
array is initially populated from the query string, but you can overwrite that if you want to without redirecting. If at some point in your code you set$_GET['foo'] = 'bar';
then that is set thereafter, no matter what the query string is.You can try updating $_GET
And then redirect users there:
You just have to make sure to redirect only when necessary, so that you don't take users into infinite redirect.
It is three ways of doing this.
One:
In the php file:
Second:
Use a questionmark behind the url, like this: http://domain.com/file.php?foo=bar&stack=overflow
Then:
Remember that your users easily can change the values of the variables.
Third:
$_GET
is populated with the params/values sent in the querystring of the url, so if you callhttp://example.com/my.php?foo=bar&foo2=baz
then in my.php$_GET['foo'] => 'bar'
and$_GET['foo2'] => 'baz'