Skip to content

Instantly share code, notes, and snippets.

@aknosis
Created January 18, 2012 23:58
Show Gist options
  • Save aknosis/1636629 to your computer and use it in GitHub Desktop.
Save aknosis/1636629 to your computer and use it in GitHub Desktop.
Read from stdin to a php variable
<?php
/**
* Usage:
* $answer = prompt("What is your quest?");
* echo "Answer: $answer";
*
* Outputs:
* What is your quest?
* I seek the holy grail!
* Answer: I seek the holy grail!
*/
function prompt($msg){
echo "$msg\n";
return trim(fgets(STDIN));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment