Skip to content

Streams

Streams provide a unified way to read and write data in PHP.

They allow accessing files, network resources, and memory using the same API.

$handle = fopen("php://memory", "r+");
fwrite($handle, "Hello Stream");
rewind($handle);
echo stream_get_contents($handle);