Skip to content

Instantly share code, notes, and snippets.

@ThijsFeryn
Created June 26, 2012 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThijsFeryn/2994427 to your computer and use it in GitHub Desktop.
Save ThijsFeryn/2994427 to your computer and use it in GitHub Desktop.
Short syntax for PHP command line I/O streams
<?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