php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64881 It's unclear how getlastmod is affected by includes/requires
Submitted: 2013-05-20 11:28 UTC Modified: 2013-11-08 08:16 UTC
From: dean at omnivisiontechnology dot com Assigned: krakjoe (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2013-05-20 11:28 UTC] dean at omnivisiontechnology dot com
Description:
------------
It isn't clear from the manual page whether getlastmod() only checks the modification date of the main script file, or whether it takes into account modification dates of all include/require files also.

Actually there are two issues:

(1)  If I use getlastmod() inside an include file, does it report the modification date of the include file, or of the main including script?

(2)  If I use getlastmod() inside a script that uses INCLUDE or REQUIRE to inline other files, and at least one of these has been modified more recently than the main including script, will this more recent modification date be returned by getlastmod()?


If the answer to (2) is NO, then perhaps there should be an extension to getlastmod() (a boolean argument perhaps) or else a separate function that DOES work this way?  A lot of webpages for example, are constructed by INCLUDE-ing a header and footer around the main content of the page; the reported modification date of the page should reflect a modification to any of these.
 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-20 20:11 UTC] mail+php at requinix dot net
1. When the documentation says "page" it really means "file" (ie, __FILE__). So
>Gets the time of the last modification of the current file.

2. PHP can't know what files may be include()d later on, but you can use 
get_included_files() and filemtime() a la the comment by Moro [1] to get the 
most recent modification date of the ones include()d so far.
IMO a feature request to bundle this into getlastmod() seems quite reasonable 
but you might want to make a separate feature request ticket so this one can 
remain a bug report.

[1] http://php.net/function.getlastmod#109250
 [2013-05-21 01:17 UTC] dean at omnivisiontechnology dot com
Ok, then what I'd suggest is that

"time of the last modification of the current page"

be changed to

"time of the last modification of the current script file" 

in both the "Description" and "Return values" section of the doc page.

Additionally it should note that this is always the modification time of the top-level script file, even if called from within an include file; modification times of include files don't count.

I'll log a separate feature request asking that functionality be added to getlastmod() to check included file modification dates also.
 [2013-11-08 08:15 UTC] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&revision=332085
Log: #64881 update wording for clarity
 [2013-11-08 08:16 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2013-11-08 08:16 UTC] krakjoe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

getlastmod either executes a SAPI handler or references a global stat cache for PATH_TRANSLATED, it does not have anything to do with __FILE__.

Documentation updated for clarity.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 07:00:01 2026 UTC