linux php常用命令,php调用Linux系统常用命令
歡迎進入Linux社區論壇,與200萬技術人員互動交流 >>進入 1、exec函數 ?php $test = "ls /tmp/test"; //ls是linux下的查目錄,文件的命令 exec($test,$array); //執行命令 print_r($array); ? 2、system函數 ?php $test = "ls /tmp/test"; $last = system($t
歡迎進入Linux社區論壇,與200萬技術人員互動交流 >>進入
1、exec函數
$test = "ls /tmp/test";?? //ls是linux下的查目錄,文件的命令
exec($test,$array);?????? //執行命令
print_r($array);
?>
2、system函數
$test = "ls /tmp/test";
$last = system($test);
print "last: $last\n";
?>
3、passthru函數
$test = "ls /tmp/test";
passthru($test);
?>
4、popen函數
$test = "ls /tmp/test";
$fp = popen($test,"r");? //popen打一個進程通道
while (!feof($fp)) {????? //從通道里面取得東西
$out = fgets($fp, 4096);
echo? $out;???????? //打印出來
}
pclose($fp);
?>
5、proc_open函數
$test = "ls /tmp/test";
$arrayarray =?? array(
array("pipe","r"),?? //標準輸入
array("pipe","w"),?? //標準輸出內容
array("pipe","w")??? //標準輸出錯誤
);
$fp = proc_open($test,$array,$pipes);?? //打開一個進程通道
echo stream_get_contents($pipes[1]);??? //為什么是$pipes[1],因為1是輸出內容
proc_close($fp);
?>
6、proc_open函數
$test = "ls /tmp/test";
$arrayarray =?? array(
array("pipe","r"),?? //標準輸入
array("pipe","w"),?? //標準輸出內容
array("pipe","w")??? //標準輸出錯誤
);
$fp = proc_open($test,$array,$pipes);?? //打開一個進程通道
echo stream_get_contents($pipes[1]);??? //為什么是$pipes[1],因為1是輸出內容
proc_close($fp);
?>
7、shell_exec函數
$test = "ls /tmp/test";
$out = shell_exec($test);
echo $out;
?>
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的linux php常用命令,php调用Linux系统常用命令的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle查询记录插入,我应该使用哪种
- 下一篇: linux安装apache下载文件,Li