If you need to read data from STDIN in a CLI based PHP script:
$str = file_get_contents("php://stdin");