2017-04-03 35 views
1

我有一個URL成爲查詢字符串與http_build_query函數。http_build_query忽略一個鍵

但我有一個參數timestamp,我無法編輯。並且&times成爲乘號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; 
+2

您能否提供示例代碼,示例以及所需的輸出 – Jpsh

+0

您可能可以在將密鑰傳入之前取消設置。或者複製陣列,取消設置密鑰並將其傳入。 – mkaatman

+1

您嘗試過什麼?提供一些代碼。 –

回答

0

@Novice是正確的,他評論我的問題:

這是一個在瀏覽器只是一個顯示問題,但你的捲曲的數據會去,就像您在您的參訪輸出顯示內容,無需添加任何東西額外只是打了就走! - 新手

當我檢查apache access.log我可以看到preffered查詢字符串張貼。

3

目前,它工作正常。問題是,當你迴應你的URL時,序列&times將使你的瀏覽器用乘法符號x代替它。要回顯並在瀏覽器中顯示正確的方式,請嘗試以下操作:

echo htmlspecialchars($url); 

這將顯示所需的URL。