Jan 30, 2008 17:40
1 function rmtmpdir($path){
2 $dir = opendir($path);
3 while (FALSE != ($file = readdir($dir))) {
4 if($file!="." && $file!="..")
5 unlink($file);
6 }
7 closedir($dir);
8 chdir('..');
9 rmdir((string)$path);
10}
The language is php. The bug emerged when I had a file named '0' in the directory. The fix is a 1 character change. Any
Leave a comment
Comments 6
Reply
Is this the correct answer because FALSE is another term for '0', therefore FALSE != '0' terminates the while statement?
Reply
Reply
Thanks for the education. :)
Reply
Reply
Leave a comment