This is a discussion on Streaming in PHP within the PHP Programming forums, part of the Web Development category; Hi, In the simplest way to explain, A stream is a resource object which exhibits streamable behavior. That is, it ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, In the simplest way to explain, A stream is a resource object which exhibits streamable behavior. That is, it can be read from or written to in a linear fashion, and may be able to fseek() to an arbitrary locations within the stream. If anybody having real experience on this u can share you valuable information
__________________ With, J. Jeyaseelan Everything Possible |
| Sponsored Links |
| |||
| Streams were introduced with PHP 4.3.0 as a way of generalizing file, network, data compression, and other operations which share a common set of functions and uses.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| A wrapper is additional code which tells the stream how to handle specific protocols/encodings. For example, the http wrapper knows how to translate a URL into an HTTP/1.0 request for a file on a remote server. There are many wrappers built into PHP by default, and additional, custom wrappers may be added either within a PHP script using stream_wrapper_register(), or directly from an extension using the API Reference in ??? 44. Because any variety of wrapper may be added to PHP, there is no set limit on what can be done with them. To access the list of currently registered wrappers, use stream_get_wrappers().
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| A stream is referenced as: scheme://target scheme(string) - The name of the wrapper to be used. Examples include: file, http, https, ftp, ftps, compress.zlib, compress.bz2, and php. If no wrapper is specified, the function default is used (typically file://). target - Depends on the wrapper used. For filesystem related streams this is typically a path and filename of the desired file. For network related streams this is typically a hostname, often with a path appended.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Stream Filters A filter is a final piece of code which may perform operations on data as it is being read from or written to a stream. Any number of filters may be stacked onto a stream. Custom filters can be defined in a PHP script using stream_filter_register(). To access the list of currently registered filters, use stream_get_filters().
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Stream Contexts A context is a set of parameters and wrapper specific options which modify or enhance the behavior of a stream. Contexts are created using stream_context_create() and can be passed to most filesystem related stream creation functions (i.e. fopen(), file(), file_get_contents(), etc...). Options can be specified when calling stream_context_create(), or later using stream_context_set_option(). A list of wrapper specific options can be found with the list of built-in wrappers (See ???? M). In addition, parameters may be set on a context using stream_context_set_params(). Currently the only context parameter supported by PHP is notification. The value of this parameter must be the name of a function to be called when an event occurs on a stream. The notification function called during an event should accept the following six parameters: void my_notifier ( int notification_code, int severity, string message, int message_code, int bytes_transferred, int bytes_max ) notification_code and severity are numerical values which correspond to the STREAM_NOTIFY_* constants listed below. If a descriptive message is available from the stream, message and message_code will be populated with the appropriate values. The meaning of these values is dependent on the specific wrapper in use. bytes_transferred and bytes_max will be populated when applicable.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Stream Errors As with any file or socket related function, an operation on a stream may fail for a variety of normal reasons (i.e.: Unable to connect to remote host, file not found, etc...). A stream related call may also fail because the desired stream is not registered on the running system. See the array returned by stream_get_wrappers() for a list of streams supported by your installation of PHP. As with most PHP internal functions if a failure occurs an E_WARNING message will be generated describing the nature of the error.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Using file_get_contents() to retrieve data from multiple sources PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Making a POST request to an https server PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Writing data to a compressed file PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| stream_copy_to_stream() used to copy data from one stream to another. Example to use PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| stream_context_create() creates and returns a stream context Example: PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| uploading and streaming video in asp.net 2.0 application | hareram | ASP and ASP.NET Programming | 2 | 08-26-2007 10:12 PM |
| Symbian C++ Mp3 Streaming | prasannavigneshr | Symbian | 8 | 08-09-2007 10:32 AM |
| What is the method for streaming transmission? | H2o | Other Web Programming Languages | 1 | 07-20-2007 01:47 AM |
| video streaming | nssukumar | Flash Actionscript Programming | 1 | 07-16-2007 06:53 AM |
| Info on Streaming | Jeyaseelansarc | Server Management | 0 | 05-18-2007 01:48 AM |