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

  • BetterCoder

    BetterCoder

    17 Aralık 2012
  • PamtheBlamofficial

    PamtheBlamof

    31 Aralık 2010
  • TheGamer2323

    TheGamer2323

    25 Ocak 2009