phpretard Posted April 17, 2008 Share Posted April 17, 2008 I can't figure why this displays nothing but error. I am trying to count the number of files in a specified folder. $dirname = "ALBUMS/".$loc; function num_files($dirname) { return count(glob($dirname)); } echo num_files(); Here is the error: Warning: Missing argument 1 for num_files(), Link to comment https://forums.phpfreaks.com/topic/101611-counting-files/ Share on other sites More sharing options...
rhodesa Posted April 17, 2008 Share Posted April 17, 2008 $dirname needs to be passed as an argument to the function, as it is not in the same scope as the function: <?php $dirname = "ALBUMS/".$loc; function num_files($dirname) { return count(glob($dirname)); } echo num_files($dirname); ?> Link to comment https://forums.phpfreaks.com/topic/101611-counting-files/#findComment-519868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.