Delete Files recursively in PHP

I think I got this from a comment from rmdir php documentation
Be careful with this one!

public static function delTree($dir) {  
   $files = array_diff(scandir($dir), array('.','..'));  
    foreach ($files as $file) {  
      (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");  
    }  
    return rmdir($dir);  
  }