Created
August 8, 2013 00:31
-
-
Save scribu/6180335 to your computer and use it in GitHub Desktop.
Proof of concept: read content from STDIN; doesn't block if there's nothing there. Works by assuming that content will be available on STDIN immediately, which might not always be the case.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$read = array(STDIN); | |
$write = null; | |
$except = null; | |
if ( stream_select($read, $write, $except, 0) > 0 ) { | |
$content = stream_get_contents($read[0]); | |
} else { | |
$content = false; | |
} | |
var_dump($content); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment