博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php 执行命令函数
阅读量:7091 次
发布时间:2019-06-28

本文共 1000 字,大约阅读时间需要 3 分钟。

/**    Method to execute a command in the terminal    Uses :     1. system    2. passthru    3. exec    4. shell_exec */function terminal($command){    //system    if(function_exists('system'))    {        ob_start();        system($command , $return_var);        $output = ob_get_contents();        ob_end_clean();    }    //passthru    else if(function_exists('passthru'))    {        ob_start();        passthru($command , $return_var);        $output = ob_get_contents();        ob_end_clean();    }     //exec    else if(function_exists('exec'))    {        exec($command , $output , $return_var);        $output = implode("n" , $output);    }     //shell_exec    else if(function_exists('shell_exec'))    {        $output = shell_exec($command) ;    }     else    {        $output = 'Command execution not possible on this system';        $return_var = 1;    }     return array('output' => $output , 'status' => $return_var);}terminal('ls');

 

转载于:https://www.cnblogs.com/yuwensong/p/5318293.html

你可能感兴趣的文章
Centos 5 配置nagios监控系统
查看>>
需求管理之如何撰写优秀的需求
查看>>
文本文件与二进制文件
查看>>
Linux 基础 - 磁盘管理 -04
查看>>
Sed 的使用方法
查看>>
RHEL6.3配置Apache服务器(1) 配置默认Web站点
查看>>
saltstack学习二:grains与pillar
查看>>
为什么应用程序用户启动时崩溃,使用xcode打开却不会
查看>>
开发第一个动态网站———使用Servlet
查看>>
通过自定义类加载器进行动态编译与动态实现接口
查看>>
ecmall后台拿Shell
查看>>
ISIS—BGP—VRRP 城域网典型架构图 拓扑实验
查看>>
浅谈oracle中row_number() over()分析函数用法
查看>>
jqGrid细节备注—jqGrid中获取subGrid的标题栏对象
查看>>
我给淘宝孙彤宇下的两个套和敬佩他的四个理由
查看>>
freemarker快速上手+空值的多种处理方法
查看>>
详解AJAX核心中的XMLHttpRequest对象
查看>>
由一幅漫画想到的
查看>>
利用SQL SERVER 2005数据库镜像实现可用性
查看>>
化堵为通 打破运维瓶颈
查看>>