JAVA、PHP、前端、APP、网站开发 - 开发技术学习

开发技术学习 » 编程开发 » PHP调用Linux系统的常用函数

PHP调用Linux系统的常用函数

PHP调用Linux系统的常用函数 例如像 1、exec函数 2、system函数 还有哪些? 1、exec函数 [php] <?php $test = "ls /tmp/test"; //ls是linux下的查目录,文件的命令 exec($test,$array); //执行命令 print_r($array); ?> [/php] 2、system函数 [php] <?php $test = "ls /tmp/test"; $last = system($test); print "last: $lastn"; ?> [/php] passthru函数 [php] $test = "ls /tmp/test"; passthru($test); [php] popen函数 [php] $test = "ls /tmp/test"; $fp = popen($test,"r"); //popen打一个进程通道 while (!feof($fp)) { //从通道里面取得东西 $out = fgets($fp, 4096); echo $out; //打印出来 } pclose($fp); [/php] proc_open函数 [php] $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); [/php] shell_exec函数 [php] $test = "ls /tmp/test"; $out = shell_exec($test); echo $out; [/php]

站点声明:部分内容源自互联网,为传播信息之用,如有侵权,请联系我们删除。

© Copyright 2011-2024 www.kfju.com. All Rights Reserved.
超级字帖 版权所有。蜀ICP备12031064号