I am running into a project that read a stream from a txt file, so in the CLI, i write:
cat texte.txt|php index.php
In my index.php file i read the stream:
$handle = fopen ("php://stdin","r");
Now i have a $result that contains the result of my processing file and i want to output it with STDOUT, I looked in the manual, but I don’t know how to use it, can you please make me a use example.
Okay, let me give you another example for the
STDINandSTDOUTusage.In PHP you use these two idioms:
When from the commandline you utilize them as such:
That’s all these things do. Piping in, or piping out. And the incoming parts will appear in
STDIN, whereas your output should go toSTDOUT. Never cross the streams, folks!