色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術文章
文章詳情頁

PHP執行linux命令的6個函數

瀏覽:112日期:2022-09-12 11:05:54
一般情況下,很少會用php去執行linux命令,不過特殊情況下,你也許會用到這些函數。以前我知道有二個函數可以執行linux命令,一個是exec,一個是shell_exec。其實有很多的,結合手冊內容,介紹以下6個函數。 1,exec函數

<?php $test = 'ls /tmp/test'; //ls是linux下的查目錄,文件的命令exec($test,$array); //執行命令print_r($array);?> 返回結果如下:

[root@krlcgcms01 shell]# php ./exec.php Array ( [0] => 1001.log [1] => 10.log [2] => 10.tar.gz [3] => aaa.tar.gz [4] => mytest [5] => test1101 [6] => test1102 [7] => weblog_2010_09 ) 2,system函數

<?php $test = 'ls /tmp/test';$last = system($test);print 'last: $lastn';?> 返回結果:

[root@krlcgcms01 shell]# php system.php 1001.log 10.log 10.tar.gz aaa.tar.gz mytest test1101 test1102 weblog_2010_09 last:weblog_2010_09 3,passthru函數

<?php $test = 'ls /tmp/test';passthru($test);?> 4,popen函數

<?php $test = 'ls /tmp/test';$fp = popen($test,'r'); //popen打一個進程通道 while (!feof($fp)) { //從通道里面取得東西 $out = fgets($fp, 4096); echo $out; //打印出來} pclose($fp);?> 5,proc_open函數

<?php $test = 'ls /tmp/test';$array = 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,shell_exec函數

<?php $test = 'ls /tmp/test';$out = shell_exec($test);echo $out;?> popen,passthru,proc_open,shell_exec的返回結果如下:

[root@krlcgcms01 shell]# php test.php 1001.log 10.log 10.tar.gz aaa.tar.gz mytest test1101 test1102 weblog_2010_09 我能發現的就這幾個函數,能執行linux下的命令,我想應當還有吧,歡迎大家補充。 來自:http://blog.51yip.com/php/1064.html

標簽: PHP
相關文章:
主站蜘蛛池模板: 亚洲精品www久久久久久久软件 | 欧美一级毛片在线播放 | 亚洲高清一区二区三区久久 | 欧美片a | 国产男女免费视频 | 99精品视频在线 | 一级特黄特黄毛片欧美的 | 看真人视频a级毛片 | 亚洲在线免费观看视频 | 草草视频在线观看 | 亚洲欧美国产一区二区三区 | 成人影院久久久久久影院 | 国产极品精频在线观看 | 久草草视频在线观看免费高清 | 成人免费夜片在线观看 | 华人色| 又www又黄又爽啪啪网站 | 日本aaaa精品免费视频 | 性欧美视频a毛片在线播放 性欧美一级 | 欧美特欧美特级一片 | 性做久久久久久久免费看 | 欧美成人中文字幕 | 波多野结衣中文在线播放 | 精品成人免费一区二区在线播放 | a毛片基地免费全部香蕉 | 亚洲高清在线播放 | 香蕉521av网站永久地址 | 久久久久欧美精品观看 | 国产在线精品二区韩国演艺界 | 久久w5ww成w人免费不卡 | 久久精品视| m男亚洲一区中文字幕 | 奇米四色综合久久天天爱 | 欧美三级在线观看不卡视频 | 怡红院在线视频观看 | 国产精品久久久久久亚洲伦理 | 欧美一级片a | 2020久久国产最新免费观看 | 青青操在线视频 | 国产亚洲一欧美一区二区三区 | 美女黄网站色一级毛片 |