2017-01-19 52 views
0

我想這一點:創建一個URL(HTTP查詢)與PHP沒有逃脫特殊的字符

datasetid=GHCND&locationid=ZIP:28801&startdate=2010-05-01&enddate=2010-05-01 

我有這樣的:

$data=['datasetid'=>'GHCND','locationid'=>'ZIP:28801','startdate'=>'2010-05-01','enddate'=>'2010-05-01']; 

我嘗試這樣做:

exit(http_build_query($data)); 

我得到這個:

datasetid=GHCND&locationid=ZIP%3A28801&startdate=2010-05-01&enddate=2010-05-01 

如何防止ZIP:28801被盜號爲ZIP%3A28801

+0

http://stackoverflow.com/questions/6132721/http-build-query-without-url-encoding – labue

回答

0

您需要urldecode這樣的字符串:

urldecode(http_build_query($data));