我需要编写一个 php 页面,该页面使用自定义查询字符串(本质上是重定向)打开现有 url。
"http://existingurl?test=pass&newparam=".$_REQUEST['u'];
怎么做?
我需要编写一个 php 页面,该页面使用自定义查询字符串(本质上是重定向)打开现有 url。
"http://existingurl?test=pass&newparam=".$_REQUEST['u'];
怎么做?
像这样:
<?php
header('Location: http://existingurl?test=pass&newparam='.urlencode($_REQUEST['u']));
exit();
?>
您只需要使用标头功能。不要忘记使用 urlencode 来保护来自 $_REQUEST['u'] 的用户输入。
<?php
header('Location: http://existingurl?test=pass&newparam='.urlencode($_REQUEST['u']));
exit();
?>
更多信息,下次可以查看官方文档。 http://php.net/manual/fr/function.header.php
header('Location: http://existingurl?test=pass&newparam='.urlencode($_REQUEST['u']));
die();
如果您可能的意思是您需要从您的 POST/GET 请求中构建一个具有多个参数的查询字符串,您可能需要查看http_build_query并将其附加到 url