讽刺英语。 我对此代码有疑问:
$rezultat=$polaczenie->query("SELECT * FROM items LIMIT 0,1");
$rezultat=mysqli_fetch_assoc($rezultat);
$rezultat=$rezultat['name'];
$connector = curl_init();
$steam='https://steamcommunity.com/market/listings/730/$rezultat';
$steam=str_replace('$rezultat',$rezultat,$steam);
echo $steam;
curl_setopt($connector, CURLOPT_URL, $steam);
curl_setopt($connector, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($connector, CURLOPT_RETURNTRANSFER, 1);
$out = curl_exec($connector);
echo "<!--".$out."-->";
curl_close($connector);
$ rezultat是“Gamma 2 Case”,$ polaczenie是来自mysqli,$ connector curl对象的对象,当我替换此行时:
curl_setopt($connector, CURLOPT_URL, $steam);
到此:
curl_setopt($connector, CURLOPT_URL,"https://steamcommunity.com/market/listings/730/Gamma 2 Case"
一切都很好。我应该做什么?
PS
当我尝试第一个代码时,返回“https://steamcommunity.com/market/listings/730/Gamma 2 Case&lt;!----&gt;”
答案 0 :(得分:0)
您需要在网址的最后部分使用rawurlencode()
来编码“”。在$resultat
:
$rezultat=rawurlencode($rezultat['name']);