I’m using readline in PHP to read from stdin, but when I run the file, PHP echos all input back to me. I’m using it like:
<file php file | otherprogram
When I run this on my server, it works like I expect, but when I run it on my laptop (PHP 5.3.10 with Suhosin-Patch (cli)) it outputs the stdin to stdout, along with the actual output of the script. This is quite annoying, as I’m piping the output to otherprogram.
I tried catching the output with output buffering, but that didn’t work.
Does anybody have any idea what might be causing this?
I know this question is a bit dated but I’m having the same issue. I believe one of two things is causing it: The readline() function in php echoes back the input it receives (one character at a time), and so it is ending up being “output” before the intended output. If that’s not it, the bash shell is echoing the input as it is being entered.
I’m somewhat inclined to believe it is the latter case because I haven’t been able to catch the output on PHP’s end, using its output buffering functions (ob_start and ob_end_clean).