PHP Command Line Confirmation Prompt


/ Published in: PHP
Save to your folder(s)

A basic confirmation question and test.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.