library/Garp/Cli.php
public static function confirm($msg) {
        print $msg . ' > ';
        system('stty -icanon');
        $handle = fopen('php://stdin', 'r');
        $char = fgetc($handle);
        system('stty icanon');
        print "\n";

        $allowedResponses = array('y', 'Y', 'n', 'N');
        if (!in_array($char, $allowedResponses)) {
            // nag 'em some more
            Garp_Cli::errorOut('Please respond with a clear y or n');
            return static::confirm($msg);
        }
        return $char === 'y' || $char === 'Y';
    }
public static function confirm($msg) {
        print $msg . ' > ';
        system('stty -icanon');
        $handle = fopen('php://stdin', 'r');
        $char = fgetc($handle);
        system('stty icanon');
        print "\n";

        $allowedResponses = array('y', 'Y', 'n', 'N');
        if (!in_array($char, $allowedResponses)) {
            // nag 'em some more
            Garp_Cli::errorOut('Please respond with a clear y or n');
            return static::confirm($msg);
        }
        return $char === 'y' || $char === 'Y';
    }
public static function confirm ( $ msg ) { print $ msg . ' > ' ; system ( 'stty -icanon' ) ; $ handle = fopen ( 'php://stdin' , 'r' ) ; $ char = fgetc ( $ handle ) ; system ( 'stty icanon' ) ; print "\n" ; $ allowedResponses = array ( 'y' , 'Y' , 'n' , 'N' ) ; if ( ! in_array ( $ char , $ allowedResponses ) ) { // nag 'em some more Garp_Cli :: errorOut ( 'Please respond with a clear y or n' ) ; return static :: confirm ( $ msg ) ; } return $ char === 'y' || $ char === 'Y' ; }
Force user to confirm a question with yes or no.

@param string $msg Question or message to display. A prompt (>) will be added.
@return bool Returns true if answer was 'y' or 'Y', no enter needed.
Force user to confirm a question with yes or no .