Api‎ > ‎Util‎ > ‎

Stdin

Class RStdin

Handy for for command line application that use keyboard input. For testing purposes the input can be faked.

Example
<?php

require_once("rawdev/RawDev.php");
require_once(RAWDEV_LIB.'/Util/Stdin.php'); 

# regular use
$input = RStdin::read('Please enter input: ');
print "$inputn";

# testing use
RStdin::$buffer[] = 'hello'; # for testing purposes the input buffer can be set
$input = RStdin::read('Please enter input: ');
print "$inputn";


?>

Vars

static string[] $buffer

A fifo buffer of faked inputs.

Functions

static string function read($message, $trim)

Reads the keyboard input ending with [enter]. The input can be faked for testing purposes (see sample).

$messagestringThe message that is displayed on the same line that the input is typed.
$trimboolWheter the input should be trimmed (default: yes).
returnsstringThe input that was entered (ending with a carriage return when not trimmed).
Comments