note 31394 deleted from function.filemtime by tomsommer

From: Date: Wed, 01 Sep 2004 17:29:24 +0000
Subject: note 31394 deleted from function.filemtime by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75863@lists.php.net to get a copy of this message
Note Submitter: benquinn at optushome dot com dot au ---- 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.

« previous php.notes (#75863) next »