Logo

Programming-Idioms

History of Idiom 120 > diff from v9 to v10

Edit summary for version 10 by :
New PHP implementation by user [nvius]

Version 9

2016-02-16, 19:09:41

Version 10

2016-02-17, 01:47:22

Idiom #120 Read integer from stdin

Read an integer value from the standard input into variable n.

Idiom #120 Read integer from stdin

Read an integer value from the standard input into variable n.

Code
fscanf(STDIN, "%d\n", $number); // reads number from STDIN
echo "Integer: {$number}\n";
Comments bubble
PHP can pull input from STDIN as an integer with %d
Doc URL
http://php.net/manual/en/features.commandline.io-streams.php
Origin
http://php.net/manual/en/features.commandline.io-streams.php