Example for reading data (bug #21428)

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@164449 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jakub Vrana 2004-07-27 13:40:02 +00:00
parent c36889d738
commit 228db2359a

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.32 $ -->
<!-- $Revision: 1.33 $ -->
<chapter id="features.commandline">
<title>Using PHP from the command line</title>
<!-- NEW DOCUMENTATION STARTS -->
@ -230,6 +230,16 @@
$stdin = fopen('php://stdin', 'r');
?>
]]>
</programlisting>
If you want to read single line from <literal>stdin</literal>, you can
use
<programlisting role="php">
<![CDATA[
<?php
$line = trim(fgets(STDIN)); // reads one line from STDIN
fscanf(STDIN, "%d\n", $number); // reads number from STDIN
?>
]]>
</programlisting>