lakilevi Posted March 23, 2010 Share Posted March 23, 2010 Hello. I need to get in some way the maximum last modification time of my php files. The problem is that in many files I use include or require. So I need to know the last modification date of the included files. Example: inlude "config.php" echo "Last modification time" // here I should display the maximum last modification time of the actual file, and also of the file "config.php" Which is the best way to do this? I don't want to change the code of the included files. Thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/196210-last-modification-time-of-the-included-files/ Share on other sites More sharing options...
Adam Posted March 23, 2010 Share Posted March 23, 2010 You may want to look into the filemtime function. Quote Link to comment https://forums.phpfreaks.com/topic/196210-last-modification-time-of-the-included-files/#findComment-1030383 Share on other sites More sharing options...
lakilevi Posted March 23, 2010 Author Share Posted March 23, 2010 Hello. Thanks for your answer. I have tried already the filemtime function, but if made a change in the included file (config.php) and made an echo filemtime() in the main file, than it took the last modification time of the main file only, not of the included file. Quote Link to comment https://forums.phpfreaks.com/topic/196210-last-modification-time-of-the-included-files/#findComment-1030384 Share on other sites More sharing options...
trq Posted March 23, 2010 Share Posted March 23, 2010 Hello. Thanks for your answer. I have tried already the filemtime function, but if made a change in the included file (config.php) and made an echo filemtime() in the main file, than it took the last modification time of the main file only, not of the included file. Then you are passing the wrong file name to the filetime() function. Quote Link to comment https://forums.phpfreaks.com/topic/196210-last-modification-time-of-the-included-files/#findComment-1030386 Share on other sites More sharing options...
Adam Posted March 23, 2010 Share Posted March 23, 2010 The files aren't linked. I think you'll have to return the modification time of both files and check which is the most recent; then display that one. Quote Link to comment https://forums.phpfreaks.com/topic/196210-last-modification-time-of-the-included-files/#findComment-1030387 Share on other sites More sharing options...
salathe Posted March 23, 2010 Share Posted March 23, 2010 You could loop over get_included_files looking for the most recently updated file. Quote Link to comment https://forums.phpfreaks.com/topic/196210-last-modification-time-of-the-included-files/#findComment-1030388 Share on other sites More sharing options...
inversesoft123 Posted March 23, 2010 Share Posted March 23, 2010 $last_modified = filemtime("config.php"); print("Last Modified "); print(date("m/j/y h:i", $last_modified)); Quote Link to comment https://forums.phpfreaks.com/topic/196210-last-modification-time-of-the-included-files/#findComment-1030390 Share on other sites More sharing options...
lakilevi Posted March 23, 2010 Author Share Posted March 23, 2010 You could loop over get_included_files looking for the most recently updated file. Wau. Thank you very much! This I wanted. This takes also recursively the included files of the included files. Super! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/196210-last-modification-time-of-the-included-files/#findComment-1030394 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.