stdin on win
| From: | n e t b r a i n | Date: | Sat, 10 Mar 2001 02:45:25 +0000 |
| Subject: | stdin on win | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-43205@lists.php.net to get a copy of this message | ||
Hi all,
anyone know if there's a similar way to read like the linux php://stdin on a
windows box? I've tried to run a simple script founded on phpbuilder.com
about a shell scripting and it seems to work in some way just for the first
"request" ...
This a "screenshoot" of my ms-dos window:
<screenshoot>
C:\Programmi\Apache Group\Apache\bin\php>php -q test.php
What is your first name? max
What is your last name? <font color=ff0000><br>
<b>Warning</b>: fopen("php://stdin","r") - No error in
<b>test.php</b> on
line
<b>38</b><br>
</font><font color=ff0000><br>
<b>Warning</b>: Supplied argument is not a valid File-Handle resource in
<b>te
t.php</b> on line <b>39</b><br>
</font><font color=ff0000><br>
<b>Warning</b>: Supplied argument is not a valid File-Handle resource in
<b>te
t.php</b> on line <b>40</b><br>
</font>
</screenshoot>
this is the code:
function read() {
$fp=fopen("php://stdin", "r");
$input=fgets($fp, 255);
fclose($fp);
return str_replace("\n", "", $input);
}
print("\nWhat is your first name? ");
$first_name = read();
print("\nWhat is your last name? ");
$last_name = read();
print("\n\n\nHello, $first_name $last_name! Nice to meet !\n");
many thanks in advance
max