gpt4 book ai didi

php - http_build_query 忽略一键

转载 作者:行者123 更新时间:2023-12-04 00:03:31 24 4
gpt4 key购买 nike

我有一个 URL,它通过 http_build_query 函数变成了一个查询字符串。

但是我有一个无法编辑的参数timestamp。而 × 变成乘号 x

有解决办法吗?

这是我传递给 http_build_query 函数的数组。

$parameters =   array(
"transaction_id"=>uniqid("FF-"),
"timestamp"=> time(),
"order_total"=>$_SESSION['total_price'],
"order_total_with_vat"=>$_SESSION['total_price'] * 1.21,
"order_vat"=>"21",
"payment_method"=>"ideal",
"payment_status"=>"1",
"customer_name"=>$_SESSION['customer_data']['naam'],
"customer_address"=>$_SESSION['customer_data']['address'],
"customer_city"=>$_SESSION['customer_data']['city'],
"customer_zipcode"=>$_SESSION['customer_data']['zipcode'],
"customer_country"=>$_SESSION['customer_data']['country'],
"customer_email"=>$_SESSION['customer_data']['email'],
"customer_telephone"=>$_SESSION['customer_data']['telephone'],
);

url 的输出:

http://somedomain/subdir/someapi/order?transaction_id=FF-58e2451c5aea9×tamp=1491223836&order_total=156695&order_total_with_vat=189600.95&order_vat=21&payment_method=ideal&payment_status=1&customer_name=t&customer_address=t&customer_city=t&customer_zipcode=t&customer_country=t&customer_email=t%40t&customer_telephone=t&product%5B0%5D=5&product%5B1%5D=5&product%5B2%5D=5&product%5B3%5D=5&product%5B4%5D=5&product%5B5%5D=5&product%5B6%5D=5

首选输出:

http://somedomain/subdir/someapi/order?transaction_id=FF-58e2451c5aea9&timestamp=1491223836&order_total=156695&order_total_with_vat=189600.95&order_vat=21&payment_method=ideal&payment_status=1&customer_name=t&customer_address=t&customer_city=t&customer_zipcode=t&customer_country=t&customer_email=t%40t&customer_telephone=t&product%5B0%5D=5&product%5B1%5D=5&product%5B2%5D=5&product%5B3%5D=5&product%5B4%5D=5&product%5B5%5D=5&product%5B6%5D=5

http_build_query 函数:

case 'POST':
curl_setopt( $curlHandler, CURLOPT_POST, true );
$url .= '?' . http_build_query( $parameters );
break;

最佳答案

目前它工作正常。问题在于,当您回显您的 URL 序列 × 时,您的浏览器会将其替换为乘法符号 x。要回应它并在浏览器中显示正确的方式,试试这个:

echo htmlspecialchars($url); 

这将显示所需的 URL。

关于php - http_build_query 忽略一键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43187254/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com