Posted By

jachin on 10/04/08


Tagged

print console commandline prompt stdin flush confirmation


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

kawash75


PHP Command Line Confirmation Prompt


 / Published in: PHP
 

A basic confirmation question and test.

  1. $message = "Are you sure you want to do this [y/N]";
  2. print $message;
  3. $confirmation = trim( fgets( STDIN ) );
  4. if ( $confirmation !== 'y' ) {
  5. // The user did not say 'y'.
  6. exit (0);
  7. }

Report this snippet  

You need to login to post a comment.