Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Created July 18, 2018 13:39
Show Gist options
  • Save matthewpoer/6bfcb6646cda2001b9e209ce863de4e7 to your computer and use it in GitHub Desktop.
Save matthewpoer/6bfcb6646cda2001b9e209ce863de4e7 to your computer and use it in GitHub Desktop.
Using `fgets` to solicit and obtain user input in PHP CLI
<?php
echo "What do you want?" . PHP_EOL;
$handle = fopen("php://stdin","r");
$input = fgets($handle);
echo "You want " . $input . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment