且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

curl return 400 bad request(url with spaces)

更新时间:2023-01-03 18:15:41

Does this maybe work?

$url = 'http://host/a b.img';
$url = str_replace(" ", '%20', $url);

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
echo $ret = curl_exec($ch);