How to use STDOUT in php

Okay, let me give you another example for the STDIN and STDOUT usage.

In PHP you use these two idioms:

 $input = fgets(STDIN);

 fwrite(STDOUT, $output);

When from the commandline you utilize them as such:

 cat "input.txt"  |  php script.php   >  "output.txt"

 php script.php  < input.txt  > output.txt

 echo "input..."  |  php script.php   |  sort  |  tee  output.txt

That’s all these things do. Piping in, or piping out. And the incoming parts will appear in STDIN, whereas your output should go to STDOUT. Never cross the streams, folks!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)