選項shell命令我有這樣的代碼:從PHP
$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
,結果相同。 所以問題是,我做錯了什麼以及如何解決它?謝謝!
是的,你打它!非常感謝! –