View Single Post
  #1 (permalink)  
Old 10-10-04, 12:32 PM
jack_mcs jack_mcs is offline
Newbie Coder
 
Join Date: Aug 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Dir showing as file

I have a test directory that contains one directory and one file. I want my program to search through this test directory and find the file. But the code is not recognizing the sub-directory as a directory and treats it as a file. The section of code where I am testing for this looks like this. I am testing in three different ways trying to find the problem.
Code:
 $dir_handle = @opendir($srce) or die("Unable to open $srce"); 
 while (false !== ($file = readdir($dir_handle))) { 
  var_dump(is_dir('$file')) . "\n"; 
  if (is_dir($file))
   echo 'Dir1 = '.$file.'<br>';
  if (filetype($file) == "dir") 
   echo 'Dir2 = '.$file.'<br>';
When the test directory is read, I get four entries:
. //should be a dir
.. //should be a dir
edited //should be a dir
file.php //should be a file

The output of var_dump is false for all four while is_dir and filetype recognize the first two as directories but the see the last two as files. Can anyone see where I might be going wrong?

Jack
Reply With Quote