prompt() public method
Prompts the user for input and validates it
public string prompt ( $text, $options = [] ) | ||
---|---|---|
$text | string |
Prompt string |
$options | array |
The options to validate the input:
An example of how to use the prompt method with a validator function. $code = $this->prompt('Enter 4-Chars-Pin', ['required' => true, 'validator' => function($input, &$error) { if (strlen($input) !== 4) { $error = 'The Pin must be exactly 4 chars!'; return false; } return true; }); |
return | string |
The user input |
Please login to continue.