如果给定的URL被重定向到另一个URL,cURL则将获取最后一个URL
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
Run Code Online (Sandbox Code Playgroud)
但是如何记录cURL提取的最后一个URL是什么?
同
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
Run Code Online (Sandbox Code Playgroud)
我们不知道获取的实际网址是什么cURL,因为$link已被重定向到最终位置.如何记录字符串中的最后位置?
Bra*_*rad 17
你可以用curl_getinfo().
http://php.net/manual/en/function.curl-getinfo.php
echo curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
Run Code Online (Sandbox Code Playgroud)