Is this a proper way to use get in php
I'm using the below for get in php without a form.
If($q)
{
header("location:d.php?q=$name");
}
Is it correc开发者_StackOverflow中文版t?
According to the specification, the URI in the location header must be an absolute URI.
But regardless of this, your code will create an (unnecessary?) redirect.
If you want to persist values between requests, a better way would to use sessions.
Although relative ones usually work, the URL specified by location:
must be an absolute URL.
Other than that, we don't know what you are doing of course, but it's an okay header redirect to another address. If $name
contains something, it will be sent to that URL as a query parameter.
精彩评论