title: Error while using $url ,from response headers of 1st Curl, in 2nd Curl , but writing url manually works
body: <p>i get next url from 1st curl's response and in echo its showing the url but when 1 put $url in 2nd curl it does not work until i write the url manually in $ch = curl_init('www.example1.com'); like this
  my php script is;</p>
  <pre><code>1st Curl
  
  
  $ch = curl_init('www.example.com');
  curl_setopt($ch, CURLOPT_GET, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  $output = curl_exec($ch);
  curl_close($ch);
  $headers = [];
  $output = rtrim($output);
  $data = explode(&quot;\n&quot;,$output);
  $headers = $data[8];
  $url = substr($headers, 10);
  
  echo $url;
  </code></pre>
  <p>/////   echo is working and showing url but in below curl it does not work when i put $url or '.$url.'
  but when i put it manually it works ..... can you give any suggestions?
  I also tried to save url in a text file and get it from there for 2nd Curl but no use</p>
  <pre><code>2nd Curl
  
  
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  $output = curl_exec($ch);
  curl_close($ch);
  </code></pre>