使用FTP上传下载文件,如果没有设置传输方式为二进制,可能会导致文件出现空行的情况,例如:

用PHP删除ftp下载导致的文件空行

使用PHP对文件的空行进行删除,使用正则:

<?php
    
    $file = './abc.inc.php';    //需要删除的文件
    $content = file_get_contents($file);
    $preg = "/(\r\n)/i";    //删除空行
    $res  = preg_replace($preg, " ", $content);

    $f = fopen('abc2.php', 'w');    //另存为
    fwrite($f, $res);
    fclose($f);

  

相关文章:

  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2021-12-15
  • 2021-06-24
  • 2022-12-23
猜你喜欢
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案