I am experimenting with some php file / stream functionality. And i am having troubles with fread.
This data is send to a php script:
baz=bomb&foo=bar&baz=bomb&foo=bar&foo=bar&baz=bomb
And that script runs this code:
<php
$fp = fopen("php://input", "rb");
fseek($fp, 3, SEEK_SET);
echo "<br>ftell: ".ftell($fp)."<br>";
echo "<br>fread(resource, 4): ".fread($fp, 4)."<br>";
fclose($fp);
The output shows:
ftell: 3
fread(resource, 4): baz=
What i am expecting that it shows is:
=bom
Why does it seem like fread sets the pointer to the beginning of the stream first and then reads? What is the point of seeking trough a stream and not being able to read from a certain position?
The php version i am using is: 7.0.8 on a windows machine.