在PHP中,system()函數用于執行外部命令并顯示輸出。其語法如下:
system(string $command, int &$return_var): string|false
參數說明:
$command:要執行的外部命令。$return_var:用于存儲命令執行的返回值。false。示例:
$output = system('ls -l', $return_var);
echo "Command returned $return_var and output: $output";
需要注意的是,system()函數會直接輸出命令執行的結果,如果需要獲取命令執行的結果并進行處理,可以使用shell_exec()函數。