system 与 exec
两者区别与联系:都会返回最后一行,命令执行成功的return返回值, 区别:system直接将输出内容echo出来,而exec将每一行输出内容保存到数组$output里。
echo "system:<br>"; $last_line = system('ls', $retval); echo "<br>".$last_line; echo "<br>".$retval; $last_line = exec("ls",$output,$retval); echo "<br><br>exec:"; echo "<br>".$last_line."<br>"; print_r($output); echo "<br>".$retval;
结果:
system:
compress compressV2.rar phpinfo.php test.php ziparchive
ziparchive
0
exec:
ziparchive
Array ( [0] => compress [1] => compressV2.rar [2] => phpinfo.php [3] => test.php [4] => ziparchive )
0