Created
June 26, 2012 08:36
-
-
Save ThijsFeryn/2994427 to your computer and use it in GitHub Desktop.
Short syntax for PHP command line I/O streams
This file contains hidden or 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 | |
while(!feof(STDIN)){ | |
$line = trim(fgets(STDIN)); | |
if(strlen($line) > 0){ | |
fwrite(STDOUT,strrev($line).PHP_EOL); | |
} else { | |
fwrite(STDERR,"An empty line was passed".PHP_EOL); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment