1.	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2.		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3.	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4.	<head>
5.		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
6.		<title>Directory Contents</title>
7.	</head>
8.	<body>
9.	<?php // Script 11.5 - list_dir.php
10.	/* This script lists the directories and files in a directory. */
11.	
12.	// Set the time zone:
13.	date_default_timezone_set('America/New_York');
14.	
15.	// Set the directory name and scan it:
16.	$search_dir = '.';
17.	$contents = scandir($search_dir);
18.	
19.	// List the directories first...
20.	// Print a caption and start a list:
21.	print '<h2>Directories</h2>
22.	<ul>';
23.	foreach ($contents as $item) {
24.		if ( (is_dir($item)) AND (substr($item, 0, 1) != '.') ) {
25.			print "<li>$item</li>\n";
26.		}
27.	}
28.	
29.	print '</ul>'; // Close the list.
30.	
31.	// Create a table header:
32.	print '<hr /><h2>Files</h2>
33.	<table cellpadding="2" cellspacing="2" align="left">
34.	<tr>
35.	<td>Name</td>
36.	<td>Size</td>
37.	<td>Last Modified</td>
38.	</tr>';
39.	
40.	// List the files:
41.	foreach ($contents as $item) {
42.		if ( (is_file($item)) AND (substr($item, 0, 1) != '.') ) {
43.		
44.			// Get the file size:
45.			$fs = filesize($item);
46.			
47.			// Get the file's modification date:
48.			$lm = date('F j, Y', filemtime($item));
49.			
50.			// Print the information:
51.			print "<tr>
52.			<td>$item</td>
53.			<td>$fs bytes</td>
54.			<td>$lm</td>
55.			</tr>\n";
56.		
57.		} // Close the IF.
58.	
59.	} // Close the FOREACH.
60.	
61.	print '</table>'; // Close the HTML table.
62.	
63.	?>
64.	</body>
65.	</html>