Writing PHP scripts on the command line is actually quite simple. You output the text in the same way as usual: print and echo both print the text to the console. The only difference here is that you cannot use HTML tags for formatting, as your code is not interpreted by the web browser (ie, "\n" will actually create a visible line break, not <br /> ).
Reading input from stdin is a bit more complicated, but all it really does is essentially use some file reader functions (e.g. fgets() , fgetc() , fscanf() ) and pass the file path (or php://stdin to STDIN php://stdin , depending on how the new version of PHP is).
And yes, there is a link for command line programming in PHP at php.net. It covers almost everything you need to know in order to work with PHP in a command line environment.
hbw
source share