在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()函数。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: php foreach遍历数组的方式有哪些