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

Stream Wrapper

A stream wrapper is additional code which tells the stream how to handle specific protocols and encodings.

PHP supports several wrappers natively, in particular file://, http://, ftp://, php://, zlib://, data://, glob://, phar://, ssh2://, rar://, ogg:// and expect://.

Custom wrappers may be registered with stream_wrapper_register(). A wrapper may write in any kind of format.

<?php

    // opening a file with the file wrapper
    $fp = fopen('file://tmp/myfile.txt', 'r+');
    
    // opening a file with the ftp wrapper
    $fp = fopen('ftp://user:password@example.com/pub/file.txt', 'r+');
    
    // opening a file with the phar wrapper
    $fp = fopen('phar://someFile.txt', 'r+');

?>

Documentation

See Also