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

  • Jeb Corliss

    Jeb Corliss

    17 Kasım 2006
  • Keith Anthe

    Keith Anthe

    26 NİSAN 2011
  • Ty Moss

    Ty Moss

    20 Kasım 2007