Join Up!
104887 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previousfile_get_wrapper_datafileatimenext
Last updated: Tue, 28 May 2002
view the printer friendly version or the printer friendly version with notes

file_register_wrapper

(PHP 4 CVS only)

file_register_wrapper -- Register a URL wrapper implemented as a PHP class

Description

boolean file_register_wrapper ( string protocol, string classname)

This function is currently only documented by the example below:

Esimerkki 1. Implementing a base64 encoding protocol

class Base64EncodingStream {
    var $fp = null;

    function stream_open($path, $mode, $options, &$opened_path)
    {
        $this->fp = fopen($path, $mode);
        return is_resource($this->fp);
    }
    function stream_close()
    {
        fclose($this->fp);
    }
    function stream_read($count)
    {
        return false; // We only allow writing
    }
    function stream_write($data)
    {
        return fwrite($this->fp, base64_encode($data));
    }
    function stream_flush()
    {
        fflush($this->fp);
        return true;
    }
    function stream_seek($offset, $whence)
    {
        return false;
    }
    function stream_gets()
    {
        return false;
    }
    function stream_tell()
    {
        return false;
    }
    function stream_eof()
    {
        return false;
    }
}
file_register_wrapper("base64", "Base64EncodingStream")
    or die("Failed to register protocol");

copy("/tmp/inputfile.txt", "base64:///tmp/outputfile.txt");
readfile("/tmp/outputfile");

file_register_wrapper() will return false if the protocol already has a handler, or if "fopen wrappers" are disabled.

Huomaa: This function was introduced in PHP 4.3.0.

User Contributed Notes
file_register_wrapper
add a note about notes
There are no user contributed notes for this page.
previousfile_get_wrapper_datafileatimenext
Last updated: Tue, 28 May 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST