Women in Technology

Hear us Roar



Article:
  Working with Files in PHP, Part 3
Subject:   line !== 'false'
Date:   2005-03-17 10:11:01
From:   Cerro
Response to: line !== 'false'

I was looking for some code to list the directory content with PHP3. The problem that i had was that i had a subdirectory named 0. Since in PHP3 there is no !== operator i did like this:


function ListDir($dir)
{
if ((file_exists($dir)) && ($dh = opendir($dir)))
{
while (($file = readdir($dh)) || (((string) $file == "0") || ($file != false)))
echo($file);
closedir($dh);
}
}


In this case the problem directory name is "0" but you can add "false" to the condition.