note 124584 added to function.filemtime

From: Date: Thu, 09 Jan 2020 10:39:21 +0000
Subject: note 124584 added to function.filemtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-213815@lists.php.net to get a copy of this message
If the file is not in the same directory as the executing script, a failure will result unless you use $_SERVER. This is because, like file_exists(), the command works on a file system, not via HTTP. So this will NOT work properly (and will probably show a warning): echo '<img src="' . $home_url . '/images/image.jpg?v=' . filemtime ($home_url . '/images/image.jpg') . '" />'; but this will: echo '<img src="' . $home_url . '/images/image.jpg?v=' . filemtime ($_SERVER['DOCUMENT_ROOT'] . '/images/image.jpg') . '" />'; The second script above will ensure any updated image is guaranteed to replace its predecessor without forcing the browser to reload the image on every visit. ---- Server IP: 45.112.84.4 Probable Submitter: 119.81.81.244 (proxied: 92.26.214.62) ---- Manual Page -- http://php.net/manual/en/function.filemtime.php Edit -- https://master.php.net/note/edit/124584 Del: integrated -- https://master.php.net/note/delete/124584/integrated Del: useless -- https://master.php.net/note/delete/124584/useless Del: bad code -- https://master.php.net/note/delete/124584/bad+code Del: spam -- https://master.php.net/note/delete/124584/spam Del: non-english -- https://master.php.net/note/delete/124584/non-english Del: in docs -- https://master.php.net/note/delete/124584/in+docs Del: other reasons-- https://master.php.net/note/delete/124584 Reject -- https://master.php.net/note/reject/124584 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#213815) next »