PHP wait for input from command line [duplicate] PHP wait for input from command line [duplicate] php php

PHP wait for input from command line [duplicate]


The php man page for the cli has a comment here detailing a solution, (copied here for anyone else looking)

<?phpecho "Are you sure you want to do this?  Type 'yes' to continue: ";$handle = fopen ("php://stdin","r");$line = fgets($handle);if(trim($line) != 'yes'){    echo "ABORTING!\n";    exit;}fclose($handle);echo "\n"; echo "Thank you, continuing...\n";?>