note 31394 added to function.filemtime
| From: | benquinn at optushome dot com dot au | Date: | Sun, 20 Apr 2003 12:57:55 +0000 |
| Subject: | note 31394 added to function.filemtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46839@lists.php.net to get a copy of this message | ||
For those wanting to get the last modified time of a remote file, try this
$domain = "www.bom.gov.au";
$file = "/images/ban650.gif";
$fp = fsockopen ($domain, 80, $errno, $errstr, 30);
$header = "HEAD $file HTTP/1.0\r\n\r\n";
if (!$fp) {
echo "$errstr ($errno)";
} else {
fputs ($fp, "$header");
while (!feof($fp)) {
$output .= fgets ($fp,128);
}
fclose ($fp);
}
echo $output;
It requests the header information only (ie doesn't download the whole file) and $output, in
this case, is :
HEADER HTTP/1.1 200 OK Date: Sun, 20 Apr 2003 12:52:29 GMT Server: Apache/1.3.27 (Unix)
Last-Modified: Wed, 30 Oct 2002 05:00:31 GMT ETag: "28c3f8-341a-3dbf676f" Accept-Ranges:
bytes Content-Length: 13338 Connection: close Content-Type: image/gif
You can then use a method of choice to grab the last modified information from the string.
The information returned varies from server to server. Some servers return the last modified date,
others don't.
--
http://www.php.net/manual/en/function.filemtime.php
http://master.php.net/manage/user-notes.php?action=edit+31394
http://master.php.net/manage/user-notes.php?action=delete+31394
http://master.php.net/manage/user-notes.php?action=reject+31394