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

  • 3biblecom

    3biblecom

    23 NİSAN 2011
  • kalabrandmusic

    kalabrandmus

    25 Kasım 2009
  • LearnCode.academy

    LearnCode.ac

    20 Aralık 2012