Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
处理请求并重定向它的最佳实践是什么?
例子 -
用户去www.mysite.com?s=1&b=2
www.mysite.com?s=1&b=2
我想重定向到
www.mysite.com?s=1&b=2&c=3
只需将变量添加到已经通过的变量$_GET,然后执行重定向:
$_GET
$params = $_GET; $params['c'] = 3; header('Location: http://www.mysite.com?' . http_build_query($params));
您可以通过使用来缩短表达式,$_GET + array('c' => 3)但您明白了:)
$_GET + array('c' => 3)