PHP调用Linux系统的常用函数
1、exec函数
<?php
$test = "ls /tmp/test"; //ls是linux下的查目录,文件的命令
exec($test,$array); //执行命令
print_r($array);
?>
2、system函数
<?php
$test = "ls /tmp/test";
$last = system($test);
print "last: $lastn";
?>
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";
$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函数
<?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);
?>
7、shell_exec函数
<?php
$test = "ls /tmp/test";
$out = shell_exec($test);
echo $out;
?>
- 1网站内部优化一点小总结
- 2企业网站优化中的内容营销
- 3网站建设之前的策划
- 4怎样测试美国主机速度
- 5新余网站建设哪里有?
- 6新余网站设计公司如何设计方案
- 7做网站优化必知三点
- 8怎么添加网站统计代码?
- 9阿里云备案流程-原备案在阿里云
- 10网站建设顺利四大原则
- 11新余网站建设公司提醒网站被降权后应该做的
- 12综合性网站建设的一点看法
- 13企业应用架构模式
- 14网站标题文字怎么修改?
- 15SNS社交网站建设方案
- 16企业为什么偏偏需要权威的网站开发企业做官网呢?
- 17怎样利用SQL注入漏洞登录后台
- 18企业网站制作应怎样设计细节
- 19备案一次可以提交几个域名?
- 20垂直B2B行业转型成功
- 21如何才能在网站建设的过程中做到内容丰富呢?
- 22三种方法使PHP生成静态html文件
- 23Discuz!二次开发添加后台管理模块
- 24企业为什么须要权威的网站设计单位做官方网站呢?
- 25怎样用Jquery 判断radio,selelct,checkbox是否选中
- 26转化率对网站的影响和改善
- 27用百度产品做优化的问题
- 28企业集团网站建设解决方案
- 29怎样隐藏服务和版本信息
- 30新余网站建设项目开发流程
成都公司:成都市成华区建设南路160号1层9号
重庆公司:重庆市江北区红旗河沟华创商务大厦18楼