PHP 反引号运行Shell命令,C程序

/*********************************************************************
 *                  PHP 反引号运行Shell命令,C程序
 * 说明:
 *     之前没有注意到PHP可以直接运行反引号来执行shell命令,这个倒是让
 * 代码简洁了不少,因为最近在PHP里面执行shell命令用的多。
 *
 *                                   2017-8-10 深圳 龙华樟坑村 曾剑锋
 ********************************************************************/


一、参考文档:
    1. Call a C program from php and read program output
        https://stackoverflow.com/questions/5555912/call-a-c-program-from-php-and-read-program-output

二、处理方法:
    1. $output = shell_exec('/path/to/your/program');
    2. $output = `/path/to/your/program`;    // 这种之前一直没想过,这种貌似更简洁的样子

三、处理字符串连接:
    "zengjf".`/path/to/your/program`

 

posted on 2017-08-10 11:13  zengjf  阅读(1699)  评论(-1)    收藏  举报

导航