使用 php 執行 system command

下面這個. 會把輸出儲存在$output

1
2
$cmd = "ls -l";
$output = shell_exec($cmd);

還有另外一種作法用 system function . 這個在執行過程就會直接顯示出來.

1
2
$cmd = "ls -l";
$output = system($cmd, $retval);

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.