Reading from standard input and writing to standard output or standard error using PHP

One of the most common command line tricks in Linux is to chain multiple commands using the pipe symbol i.e. you feed the output of one command as the input of another. This is called standard input and standard output redirection. PHP is usually used to program for the web but it can also be used as a shell scripting language to automate tasks and like any good shell scripting language it is possible to read from standard input and write to standard output using PHP.

Continue reading