Re: Newbie needs recommendation for fast learning a little php.
Arno Welzel <[email protected]> Thu, 1 Jul 2021 10:49:18 +0200
| Newsgroups | comp.lang.php,alt.comp.lang.php,alt.php |
|---|---|
| Message-ID | <[email protected]> |
[email protected]: > On Wed, 30 Jun 2021 15:09:57 +0200, Arno Welzel <[email protected]> > wrote: [...] >> Much simpler: >> >> <?php >> echo "This file was last modified on: "; >> echo date("Y-m-d H:m",filemtime($_SERVER["SCRIPT_FILENAME"])); >> ?> > > Thanks for that. I've plugged this in and saved it as foo.php and I > get an odd reaction. The actual time stamp on the file is 13:22, but > the above script is telling me that the file was last modified at > 13:06. I suppose that the idiots at my Web host may have screwed up > something on the server. The 13:22 time is when I created the file, so > it can't be that it's showing when it was created and not when it was > modified. I'm scratching my head here. You can also try this to make sure the file system cache is emptied: <?php clearstatcache($_SERVER["SCRIPT_FILENAME"]); echo "This file was last modified on: "; echo date("Y-m-d H:m",filemtime($_SERVER["SCRIPT_FILENAME"])); ?> And if this doesn't work, use a global cache clear: <?php clearstatcache(); echo "This file was last modified on: "; echo date("Y-m-d H:m",filemtime($_SERVER["SCRIPT_FILENAME"])); ?> Also see: <https://www.php.net/manual/en/function.clearstatcache.php> >> Also see: >> >> <https://www.php.net/manual/en/reserved.variables.server.php> >> >> "'SCRIPT_FILENAME' >> >> The absolute pathname of the currently executing script." > > Okay, I don't understand what you mean in the piece immediately above > this. The above url seems to say that the script will just run. $_SERVER is a super global array which provides a number of runtime parameters of the current script. $_SERVER["SCRIPT_FILENAME"] contains the complete name of the current script including the path or the name which was passed at command line when using PHP as CLI. -- Arno Welzel https://arnowelzel.de