开发者

Is this a proper way to use get in php

开发者 https://www.devze.com 2023-02-13 11:45 出处:网络
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 he

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消