Skip to content

Instantly share code, notes, and snippets.

@jachin
jachin / prompt.php
Created June 21, 2011 04:34
PHP Command Line Confirmation Prompt
$message = "Are you sure you want to do this [y/N]";
print $message;
flush();
ob_flush();
$confirmation = trim( fgets( STDIN ) );
if ( $confirmation !== 'y' ) {
// The user did not say 'y'.
exit (0);
}