function baglan($url,$ref=false)
{
if(!$ref)
{
$ref = $url;
}
      $ch = curl_init();
      $timeout = 0;
      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36");
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_HEADER, false);
      curl_setopt($ch, CURLOPT_REFERER,$ref);
      curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
      curl_setopt($ch, CURLOPT_TIMEOUT, 15);
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
      $veri= curl_exec($ch);
      curl_close($ch);
      return $veri;
}
while (!empty(bağlan)){
echo baglan($url, "test");
}