What potential issues can arise when trying to retrieve a redirected URL using cURL in PHP and how can they be resolved?

When trying to retrieve a redirected URL using cURL in PHP, the potential issue that can arise is that cURL may not automatically follow redirects. To resolve this, you can set the `CURLOPT_FOLLOWLOCATION` option to `true` in your cURL request.

$url = 'http://example.com/redirected-url';
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$response = curl_exec($ch);

if($response === false){
    echo 'Error: ' . curl_error($ch);
}

curl_close($ch);

echo $response;