ConsoleInput
in package
Object wrapper for interacting with stdin
Table of Contents
Properties
- $_canReadline : bool
- Can this instance use readline? Two conditions must be met: 1. Readline support must be enabled.
- $_input : resource
- Input value.
Methods
- __construct() : mixed
- Constructor
- dataAvailable() : bool
- Check if data is available on stdin
- read() : string|null
- Read a value from the stream
Properties
$_canReadline
Can this instance use readline? Two conditions must be met: 1. Readline support must be enabled.
protected
bool
$_canReadline
- Handle we are attached to must be stdin. Allows rich editing with arrow keys and history when inputting a string.
$_input
Input value.
protected
resource
$_input
Methods
__construct()
Constructor
public
__construct([string $handle = 'php://stdin' ]) : mixed
Parameters
- $handle : string = 'php://stdin'
-
The location of the stream to use as input.
dataAvailable()
Check if data is available on stdin
public
dataAvailable([int $timeout = 0 ]) : bool
Parameters
- $timeout : int = 0
-
An optional time to wait for data
Return values
bool —True for data available, false otherwise
read()
Read a value from the stream
public
read() : string|null
Return values
string|null —The value of the stream. Null on EOF.