"sample1.php?q="+str
此代码用于发送需要发送多个变量的单个参数
答案 0 :(得分:0)
定义“多个值”。如果您指的是多个变量,则可以执行以下操作:
$url = "sample1.php?q=".$str."&second=".$str2;
答案 1 :(得分:0)
试试这段代码:
<script>
function make_full_url(Page_URL,Params) {
Page_URL += "?";
for Key in Params
Page_URL += Key+"="+Params[Key]+"&";
return Page_URL;
}
//test
Page_URL = "sample1.php";
Params = new Array();
Params["q"] = Str;
Params["something"] = "something";
Full_URL = make_full_url(Page_URL,Params);
</script>
答案 2 :(得分:0)
对于HTML:
"sample1.php?q=" + str + "&otherParam=" + other;
对于XHTML / XML:
"sample1.php?q=" + str + "%26otherParam=" + other;
答案 3 :(得分:0)
我希望我理解你的正确...用你的值制作一个数组并循环键值以连接你的url字符串
$values = array('q' => $str, 'val2' => $val2);
$url = 'sample1.php';
$pos = 0;
foreach($values as $key => $value) {
$url .= ($pos>0 ? '&' : '?').$key.'='.urlencode($value);
$pos++;
}