如何删除php include中的“&”替换为“&

bhmjp9jg  于 2023-01-08  发布在  PHP
关注(0)|答案(1)|浏览(1331)
$merchantRefNumber = $payment[ID];
$signature = $merchantCode.$merchantRefNumber.$secureKey;
$signature = hash('sha256', $signature);
$URL = ("https://www.atfawry.com/ECommerceWeb/Fawry/payments/status?merchantCode=".($merchantCode)."&merchantRefNumber=".($merchantRefNumber)."&signature=".($signature));

$response =  file_get_contents($URL);
if ( $response )
{

这是它在此代码中显示的链接

https://www.atfawry.com/ECommerceWeb/Fawry/payments/status?merchantCode=CB8Q95Jr&merchantRefNumber=AGHUY&signature=135bfd157a9ac13931b512120609dc31ff31879

并且它应该显示为没有amp;

https://www.atfawry.com/ECommerceWeb/Fawry/payments/status?merchantCode=CB8Q95Jr&merchantRefNumber=AGHUY&signature=135bfd157a9ac13931b512120609dc31ff31879
mtb9vblg

mtb9vblg1#

尝试使用http_build_query

$url = "https://www.atfawry.com/ECommerceWeb/Fawry/payments/status";
$data = array(
    'merchantCode' => $merchantCode,
    'merchantRefNumber' => $merchantRefNumber,
    'signature' => $signature
);

$response = file_get_contents($url . "?" . http_build_query($data));

另请参阅:https://www.php.net/manual/en/function.http-build-query.php

相关问题