getlastmod() function

Open a directory, read contents into variable, cycle through variable content one
item at a time, printing list of files in directory in table
last td contains modifcation date

Back to Bill's PHP

Begin PHP output

File NameLast ModifiedDate
. was last modified 05/17/18
.. was last modified 05/17/18
lunchForm.html was last modified 05/17/18
rewinddir.php was last modified 05/17/18
file7-6.txt was last modified 05/17/18
translateArray.php was last modified 05/17/18
writeTable.php was last modified 05/17/18
getLastMod.php was last modified 05/17/18
fgets.php was last modified 05/17/18
data.txt was last modified 05/17/18
file7_7.txt was last modified 08/17/18
elseifTest.php was last modified 05/17/18
lastLogClass.php was last modified 05/17/18
stat.php was last modified 05/17/18
opendir.php was last modified 05/17/18
file.php was last modified 05/17/18
phpinfo.php was last modified 05/17/18
recursion.php was last modified 05/17/18
whileTest.php was last modified 05/17/18
popen_pclose.php was last modified 05/17/18
getCurrentUser.php was last modified 05/17/18
fileIO.php was last modified 05/17/18
closedir.php was last modified 05/17/18
lunchCost.php was last modified 05/17/18
End PHP output

Back to Bill's PHP

Using the <pre> tag, we show the code below which produces the results shown below the code. The code you see below is also run "behind the scenes" in PHP

<?

// print("<ul>\n");

/*
/** open directory and assign to variable 
*/

$myDirectory = opendir(".");

// Start table outside of loop

print("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\" width=\"300\">");

// Get each entry by running readdir() on variable

while($entryName = readdir($myDirectory)) {
print("<tr>");
print("<td bgcolor=lightgrey>");
print("<font color=seagreen>");
print($entryName);
print("</font>");
print("</td>");
print("<td>");
printf("    was last modified</td><td bgcolor=\"336600\"> <font color=lightgrey>%s</font></td>",date("m/d/y", getLastMod()));
print("</td>");
print("</tr>");
}
print("</table>");
/*
/** Close directory
*/

closedir($myDirectory);
// print("\n");

?>

Back to Bill's PHP