1

I would like to know, how use "filemtime" with all link ?

Example : - My PHP file for get is : http://mywebsite.org/getdate.php - The link that I want to get the date is : http://thegoodwebsite.net/i/banp.gif

Thanks in advance for your help!

Aymeric98
  • 137
  • 2
  • 2
  • 9

1 Answers1

1

The built-in http wrapper doesn't support stat family of functionality, like filemtime. So: you can't.

HTTP protocol define a Last-Modified header field that you may use instead. With CURL:

$curl = curl_init('http://thegoodwebsite.net/i/banp.gif');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_FILETIME, true);

if (false !== curl_exec($curl)) {
    $time = curl_getinfo($curl, CURLINFO_FILETIME);
    echo 'remote time of the retrieved document: ', $time;
}

curl_close($curl); 

If you get -1 it might be unknown.

Federkun
  • 36,084
  • 8
  • 78
  • 90