【发布时间】:2017-07-20 09:34:24
【问题描述】:
我有这个代码:
$codif ="file --mime-encoding -b inputfile.txt";
$codif = shell_exec($codif);
$encode = "iconv --from-code=$codif --to-code=UTF-8 --output=tempfile.txt inputfile.txt";
我试过了
shell_exec($encode); //1
exec($encode); //2
system($encode); //3
我有这个只是为了看看生成的命令是什么:
echo $encode;
哪个输出这个:
iconv --from-code=iso-8859-1 --to-code=UTF-8 --output=tempfile.txt inputfile.txt
问题是执行命令的三种形式中的任何一种都会出现下一个错误:
sh: 2: --to-code=UTF-8: not found
在 shell 中执行输出命令时效果很好。
我还尝试将--to-code=UTF-8 更改为-t UTF-8,结果相同。
所以问题是,我做错了什么以及如何解决它?谢谢!
【问题讨论】: