You appear to be a bot. Output may be restricted
Description
Prompt for a response from stdinOnly echo if we're going to pause, or are skipping
Usage
$string = oikb_get_response( $text, $pause );
Parameters
- $text
- ( string ) optional default: Continue? – prompt for the response
- $pause
- ( bool ) optional – force a pause even when the response is "go"
Returns
string the trimmed responseSource
File name: oik-batch/oik-login.incLines:
1 to 29 of 29
function oikb_get_response( $text="Continue?", $pause=false ) { static $resp = false; $response = $resp; if ( $pause || ( $resp !== "g" ) && ( $resp !== "s" ) ) { echo "$text ( y=yes/n=no/s=skip/g=go/q=quit )"; $stdin = fopen( "php://stdin", "r" ); $response = fgets( $stdin ); fclose( $stdin ); } $resp = strtolower( substr( trim( $response ), 0, 1 ) ); switch ( $resp ) { case "n": case "s": $response = false; break; case "q": echo "Ending"; die(); break; case "": $response = true; break; default: // Let the caller determine break; } oikb_check_time_limit(); return( $response ); }View on GitHub