- feof: documentation ( source)
- fwrite: documentation ( source)
- ftell: documentation ( source)
- fseek: documentation ( source)
- fread: documentation ( source)
- fopen: documentation ( source)
<?php
$data = "foo";
$stream = fopen('php://memory', 'r+');
fwrite($stream, $data);
fseek($stream, 0);
if ($data !== fread($stream, strlen($data)+1)) {
throw new \Exception("Invalid data");
}
if (strlen($data) !== ftell($stream)) {
throw new \Exception("Invalid tell");
}
if (feof($stream) !== true) {
throw new \Exception("Invalid eof");
}