Alternatively, if your running under Linux, you could make use of whats already in the os and shell out some commands: -
find \! -type d | wc -l
will return the number of files (recursively) from the directory it is run in. To run on a specified directory just add the path you want to start from, i.e.
find /usr/share \! -type d | wc -l
BTW, this will list all files (including hidden files) but not including "." and ".."
So - thats the file count, and space usage can be done in much the same way
du -s
will give you a file usage summary for all the files from the current directory downwards (including hidden files, but excluding "." and "..") in Kb.
For bytes use
du -sb
or a "human readable format" with
du -sh
Anyhow - just an alternative to PHP 🙂