Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

php://memory

php://memory is a special read-write stream that gives access a space in memory. It is removed at the end of execution of the current code, so this stream is ideal for temporary and fast storage.

php://memory always stays in memory, so it may reach the memory limit of PHP. On the other hand, php://tmp does the same, but overflows to disk when needed.

<?php

    file_put_contents('php://memory', $data);
    
    $data = file_get_contents('php://memory');

?>

Documentation

See Also