note 20727 modified in ref.readline by sander
| From: | sander@php.net | Date: | Sun, 14 Apr 2002 11:34:04 +0000 |
| Subject: | note 20727 modified in ref.readline by sander | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-29262@lists.php.net to get a copy of this message | ||
[Ed. note: you can use fopen("php://stdin", "w") to achieve the same thing,
works on both Windows and Unix)]
I wanted to get console input in a PHP script running on windows, so I made a little hack, which is
so simple, it is clearly public domain. What I did was write a C++ program to get a line, then
output it. Then all that is needed is to exec() that program and capture the output - readline()
for windows. The C++ source is as follows:
#include <iostream.h>
#include <string>
void main()
{
string input;
cin >> input;
cout << input;
}
It works wonderfully for my purposes, since I love the PHP language and want to have console input.
Justin Henck
--was--
I wanted to get console input in a PHP script running on windows, so I made a little hack, which is
so simple, it is clearly public domain. What I did was write a C++ program to get a line, then
output it. Then all that is needed is to exec() that program and capture the output - readline()
for windows. The C++ source is as follows:
#include <iostream.h>
#include <string>
void main()
{
string input;
cin >> input;
cout << input;
}
It works wonderfully for my purposes, since I love the PHP language and want to have console input.
Justin Henck
http://www.php.net/manual/en/ref.readline.php