read() public méthode

Reads the given amount of characters from the input stream.
public read ( integer $length, string $default = null ) : string
$length integer The number of characters to read.
$default string The default to return if interaction is disabled.
Résultat string The characters read from the input stream.
Exemple #1
0
 /**
  * Reads the given amount of characters from the standard input.
  *
  * @param int    $length  The number of characters to read.
  * @param string $default The default to return if interaction is disabled.
  *
  * @return string The characters read from the input.
  *
  * @throws IOException If reading fails or if the standard input is closed.
  */
 public function read($length, $default = null)
 {
     return $this->input->read($length, $default);
 }
Exemple #2
0
 public function testReadReturnsDefaultIfNotInteractive()
 {
     $this->stream->set('Lorem ipsum');
     $this->input->setInteractive(false);
     $this->assertSame('Default', $this->input->read(20, 'Default'));
 }