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

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


一、参考文档:
1. Call a C program from php and read program output
https:
//*.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`