SORU
17 ŞUBAT 2010, ÇARŞAMBA


Nasıl bir URL PHP ile varsa kontrol edebilirim?

Nasıl bir URL () 404 değil PHP içinde olup olmadığını kontrol edebilirim?

CEVAP
17 ŞUBAT 2010, ÇARŞAMBA


Burada:

$file = 'http://www.domain.com/somefile.jpg';
$file_headers = @get_headers($file);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
    $exists = false;
}
else {
    $exists = true;
}

Buradan: http://www.php.net/manual/en/function.file-exists.php#75064

...ve right below yukarıdaki yazı, curl bir çözüm var:

function url_exists($url) {
    if (!$fp = curl_init($url)) return false;
    return true;
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • beautyexchange

    beautyexchan

    4 EYLÜL 2006
  • Damian Winter

    Damian Winte

    27 ŞUBAT 2007
  • gadgetgal38

    gadgetgal38

    9 HAZİRAN 2009