Passing data between PHP and C executable in linux

前端 未结 4 560
迷失自我
迷失自我 2021-01-12 15:12

Under Linux ,if I want to pass pure string from PHP to C, how do i do that? what I\'ve tried do far is:

exec(\"./myexec.bin -a mystring\");

4条回答
  •  长情又很酷
    2021-01-12 15:34

    try using echo and pipe the output to your C executable instead of using args:

    exec("/bin/echo | ./myexec.bin");

    as @sarnold mentioned in comments it's wrong. Look at @Linus Kleen answer.

    in your C program:

    fopen(stdin, "r");
    // ...
    

提交回复
热议问题