PHP 8.5.0 Alpha 4 available for testing

Voting

: min(six, six)?
(Example: nine)

The Note You're Voting On

Anonymous
23 years ago
[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

<< Back to user notes page

To Top