In Turbo Pascal we have the read();
function. Is there a function to get variables, sent to any script on PHP?
Asked
Active
Viewed 297 times
1

Peter Mortensen
- 30,738
- 21
- 105
- 131

Taras Lukavyi
- 1,339
- 2
- 14
- 29
-
Turbo Pascal programs and PHP scripts are typically run in totally different environments. There's no direct analogue. – el.pescado - нет войне Oct 12 '15 at 15:44
2 Answers
2
Are you maybe looking for the eval() function? http://php.net/manual/en/function.eval.php

Stephan Grobler
- 469
- 1
- 5
- 17
-
I think he is looking for a way to parse an incoming stream (textual?) into various variables (with possibly different typing). More or less Fscanf like functionality. – Marco van de Voort Mar 20 '12 at 13:04
2
The Turbo Pascal read() and readln() functions read from file. If no filename is specified, they read from standard input.
In PHP, you have to open the file first, then read from the file handle allocated on open: the equivalent of standard input in PHP is php://input, so something like:
$filename = "php://input";
$handle = fopen($filename, "r");
$contents = fread($handle, 1024);
fclose($handle);
But note that it's not particularly practical to do this from a web interface, only from the CLI

Mark Baker
- 209,507
- 32
- 346
- 385
-
-
read() in turbo Pascal can read _typed_ data. So if the file is textual, and you read an integer typed variable, it will read till the first non digit, and convert from string to integer. (with IOResult variable that can be tested for errors) – Marco van de Voort Mar 20 '12 at 13:02