<?php
function countFiles($strDirName)
{
if ($hndDir = opendir($strDirName))
{
$intCount = 0;
while (false !== ($strFilename = readdir($hndDir)))
{
if ($strFilename != "." && $strFilename != "..")
{
$intCount++;
}
}
closedir($hndDir);
}
else
{
$intCount = -1;
}
return $intCount;
}
echo countFiles("uploads/");
?>
Why the class? No point, just makes this run slower.
I see, well good job testing it then. A few suggestions (pretending OOP was the right choice here):
- You should be using interfaces.
- Some of these functions could be abstracted.
- Pointers could be used.
- The function visibility should be properly done (you only coded one function properly).
So you can do a better job next time
I know i can get a infraction for this but i think the thread should be up still its worth it and i need help with it