note 30514 added to function.getlastmod
| From: | timeflys at users dot sourceforget dot net | Date: | Thu, 20 Mar 2003 19:28:43 +0000 |
| Subject: | note 30514 added to function.getlastmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45567@lists.php.net to get a copy of this message | ||
I found issues using getlastmod() to test whether or not I was successful in setting the Last
Modified date in the header. The code below shows the same Last Modified date before and after I set
the Last-Modified header.
=====getlastmod
<?
//True modified date
$modified = date ("F d Y H:i:s.", getlastmod());
//artificial modified date - sent to header
$last_modified = gmdate('D, d M Y H:i:s T', (time() - 43200));
//caching prevention
header("Last-Modified: $last_modified GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
$getlast_modified = date ("F d Y H:i:s.", getlastmod());
print "True modified date(Before): $modified <p /> Date sent to header(After):
$getlast_modified";
?>
I then used the PEAR, HTTP_Request class which worked, the Last-Modified date updates everytime it
is requested, the desired effect.
======HTTP_Request
<?
require 'HTTP/Request.php';
$r = new HTTP_Request('http://www.sample.com/page.php');
$r->sendRequest();
$response_headers = $r->getResponseHeader();
print $response_headers["last-modified"];
?>
--
http://www.php.net/manual/en/function.getlastmod.php
http://master.php.net/manage/user-notes.php?action=edit+30514
http://master.php.net/manage/user-notes.php?action=delete+30514
http://master.php.net/manage/user-notes.php?action=reject+30514