php DO not use trailing slash DIR_NAME tmp dh opendir DIR_NAME while f

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<?php
# DO not use trailing slash!!!
$DIR_NAME = '/tmp';
$dh = opendir($DIR_NAME);
while(false !== ($row = readdir($dh))) {
if ('.' == $row or '..' == $row) {
continue;
}
if (is_dir($DIR_NAME . '/' . $row)) {
print 'foobar' . $row . "\n";
}
}
?>