\Inhere\Console\Component\InteractQuestion

Class Question

Summary

Methods
Properties
Constants
ask()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

ask()

ask(string  $question, string  $default = '', \Closure|null  $validator = null) : string

Ask a question, ask for results; return the result of the input

Parameters

string $question
string $default
\Closure|null $validator

Validator, must return bool.

Returns

string

Examples

is an example ```php $answer = Interact::ask('Please input your name?', null, function ($answer) { if (!preg_match('/\w{2,}/', $answer)) { // output error tips. Interact::error('The name must match "/\w{2,}/"'); return false; } return true; }); echo "Your input: $answer"; ``` ```php // use the second arg in the validator. $answer = Interact::ask('Please input your name?', null, function ($answer, &$err) { if (!preg_match('/\w{2,}/', $answer)) { // setting error message. $err = 'The name must match "/\w{2,}/"'; return false; } return true; }); echo "Your input: $answer"; ```
** File not found : This **