Skip to content

Instantly share code, notes, and snippets.

@alana314
Created November 28, 2017 01:24
Show Gist options
  • Save alana314/f633a58c68a7d923139b891065365133 to your computer and use it in GitHub Desktop.
Save alana314/f633a58c68a7d923139b891065365133 to your computer and use it in GitHub Desktop.
Use PHP to interact with stdin
while(true):
echo "Are you sure you want to do this? Type 'yes' to continue: ";
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
if(trim($line) == 'yes'){
break;
}
endwhile;
fclose($handle);
echo "\n";
echo "Thank you, continuing...\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment