zoukankan      html  css  js  c++  java
  • php调用linux命令

    php有以下接口可提供执行外部函数:

      system()

      exec()

      popen()

    但要使用上面几个函数,首先,要配置php.ini配置文件。修改配置文件如下:

      safe_mode = off;

    改成

      safe_mode = on;

    函数使用讲解:

      string system ( string $command [, int &$return_var ] )

      参数讲解:

        $command:该命令将会被执行

        $return_var:将会返回执行该命令的返回值

      示例:

        system("ls -la", $return_var);

        print_r();//打印出该脚本的目录的所有详细文件名

       string exec(string command, string [array], int [return_var]);

      参数详解:

        $command:该命令会被执行

        $return_var:将会返回执行该命令的返回值  

       示例:

        $test = exec("ls -la");

        print_r($test);//成功返回0,

      

      file popen(command,mode);

      参数详解:

        $command:该命令会被执行

        $mode:设置读写模式

      示例:

      $file = popen("/bin/ls","r");

      //一些要执行的代码

       pclose($file);

    备注:以上示例只是简单的示范,要详细了解,还是要多用用搜索引擎。

  • 相关阅读:
    流光shader 和 流光+扭曲shader
    unity3d android动态更新dll
    Shader之溶解效果的几种实现方法
    我的第一个法线贴图
    windows 函数
    MFC 消息框
    C++ MFC棋牌类小游戏day1
    C++STL 预定义函数对象和函数适配器
    C++STL 函数对象和谓词
    C++STL 算法
  • 原文地址:https://www.cnblogs.com/sustudy/p/4195325.html
Copyright © 2011-2022 走看看