Logo

Programming-Idioms

History of Idiom 120 > diff from v25 to v26

Edit summary for version 26 by programming-idioms.org:
[PHP] Var name is n. No need to echo.

Version 25

2016-11-18, 10:35:53

Version 26

2016-11-18, 10:36:55

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