Skip to content

Instantly share code, notes, and snippets.

@alana314
alana314 / commandlineinteractive.php
Created November 28, 2017 01:24
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";