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

  • CHISTOSITOJAJA

    CHISTOSITOJA

    27 HAZİRAN 2010
  • GoldgenieOfficial

    GoldgenieOff

    23 Temmuz 2009
  • Manuel Vizcaino

    Manuel Vizca

    27 Mayıs 2008