Multiple input with proc_open()

前端 未结 1 1126
南笙
南笙 2021-01-21 18:18

I\'m currently working on an online program. I\'m writing a php script that executes a command in the command line with proc_open() (under Linux Ubuntu). This is my code so far:

相关标签:
1条回答
  • 2021-01-21 18:45

    You forgot to write a newline to the pipe, so your program will think that it got only 45 as input. Try this:

    fwrite($pipes[0], "4");
    fwrite($pipes[0], "\n");
    fwrite($pipes[0], "5");
    fclose($pipes[0]);
    

    Or shorter:

    fwrite($pipes[0], "4\n5");
    fclose($pipes[0]);
    
    0 讨论(0)
提交回复
热议问题