To read a line from standard input in php CLI mode, you can do:
$fin = fopen ("php://stdin","r");
$line = fgets($fin);
On older versions of PHP STDIN
constant may also work
$line = fgets(STDIN);
To read all the content from input use:
file_get_contents('php://input');