在Windows上运行的PHP命令行工具


PHP command-line tool to work on Windows

下面的所有代码/命令都是从命令行处理图像的PHP脚本的一部分,它适用于Linux系统,我需要弄清楚如何翻译这些命令以在Windows系统上工作。

我想过可能将其切换为使用本机 PHP 文件系统函数,但我不确定,因为下面这些命令中的-rf-f之类的东西。

有人可以帮我吗,我需要翻译下面的 5 个以在 Windows 系统上的 PHP 脚本中工作,而不是 Unix/linux

line 100
exec("rm -rf {$this->tmp_path}");
line 219
exec("rm -f $raw_file");
line 281
exec("mv $quant_file {$this->tmp_path}/{$src_filename}-quant.png");
line 289
exec("rm -f $quant_file");
line 295
exec("rm -f $out_file");
  • rm -rfrd /s /q
  • rm -fdel /f
  • mvmove

当然,如果您希望脚本Windows和Unix上运行,那么您还有更多工作要做。但是PHP原生函数(rmdirunlinkrename(在这种情况下使用是微不足道的,实际上:

rmdir($this->tmp_path);
unlink($raw_file);
rename($quant_file, "{$this->tmp_path}/{$src_filename}-quant.png");
unlink($quant_file);
unlink($out_file);

(粗略地说,它未经测试,我已经五年没有接触过PHP。