altonbr
November 7th, 2007, 04:45 PM
I have an extremely simple script taken from http://ca3.php.net/opendir to count files inside a directory.
How come my top two $dir paths don't return a value? Is it a limitation of php-cli to read outside of the current directory?
<?php
//get path of directory containing this script
//$dir = "/home/brett/.wine/drive_c/Program\ Files/Rockstar\ Games/Grand\ Theft\ Auto\ Vice\ City/mp3/";
//$dir = "/home/brett/.wine/drive_c/Program Files/Rockstar Games/Grand Theft Auto Vice City/mp3/";
$dir = './';
//open a handle to the directory
$handle = opendir($dir);
//intitialize our counter
$count = 0;
//loop through the directory
while (false !== ($file = readdir($handle))) {
//evaluate each entry, removing the . & .. entries
if (is_file($file) && $file !== '.' && $file !== '..') {
$count++;
}
}
echo ("-- $count files \n\r");
?>
How come my top two $dir paths don't return a value? Is it a limitation of php-cli to read outside of the current directory?
<?php
//get path of directory containing this script
//$dir = "/home/brett/.wine/drive_c/Program\ Files/Rockstar\ Games/Grand\ Theft\ Auto\ Vice\ City/mp3/";
//$dir = "/home/brett/.wine/drive_c/Program Files/Rockstar Games/Grand Theft Auto Vice City/mp3/";
$dir = './';
//open a handle to the directory
$handle = opendir($dir);
//intitialize our counter
$count = 0;
//loop through the directory
while (false !== ($file = readdir($handle))) {
//evaluate each entry, removing the . & .. entries
if (is_file($file) && $file !== '.' && $file !== '..') {
$count++;
}
}
echo ("-- $count files \n\r");
?>