convert.php 1012 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. //解决eclipse编码GBK转换为utf-8编码问题
  3. //项目文件放在src文件夹
  4. //访问:http://others.yoqi.me/convert.php
  5. function listDir($dir)
  6. {
  7. echo "start!";
  8. if(is_dir($dir))
  9. {
  10. if ($dh = opendir($dir))
  11. {
  12. while (($file = readdir($dh)) !== false)
  13. {
  14. if((is_dir($dir."/".$file)) && $file!="." && $file!="..")
  15. {
  16. //进入子文件夹
  17. rename($dir."/".$file,$dir."/".mb_convert_encoding($file,"GBK", "UTF-8"));
  18. listDir($dir."/".$file."/");
  19. }
  20. else
  21. {
  22. if($file!="." && $file!="..")
  23. {
  24. rename($dir."/".$file,$dir."/".mb_convert_encoding($file,"GBK", "UTF-8"));
  25. echo $dir."/".$file;
  26. }
  27. }
  28. }
  29. closedir($dh);
  30. }
  31. }
  32. echo "finish!";
  33. }
  34. //开始运行
  35. listDir("E:/web/iis/teleport");
  36. ?>