<HTML ><HEAD ><TITLE >Streams API for PHP Extension Authors</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="PREVIOUS" TITLE="API Macros" HREF="zend.api-macros.html"><LINK REL="NEXT" TITLE="Streams Basics" HREF="streams.basics.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="chapter" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="zend.api-macros.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="streams.basics.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="chapter" ><H1 ><A NAME="streams" >Chapter 43. Streams API for PHP Extension Authors</A ></H1 ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT ><A HREF="streams.html#streams.overview" >Overview</A ></DT ><DT ><A HREF="streams.basics.html" >Streams Basics</A ></DT ><DT ><A HREF="streams.resources.html" >Streams as Resources</A ></DT ><DT ><A HREF="stream.common-api.html" >Streams Common API Reference</A ></DT ><DT ><A HREF="streams.dir-api.html" >Streams Dir API Reference</A ></DT ><DT ><A HREF="streams.file-api.html" >Streams File API Reference</A ></DT ><DT ><A HREF="streams.socket-api.html" >Streams Socket API Reference</A ></DT ><DT ><A HREF="streams.structs.html" >Streams Structures</A ></DT ><DT ><A HREF="streams.constants.html" >Streams Constants</A ></DT ></DL ></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="streams.overview" ></A >Overview</H1 ><P > The PHP Streams API introduces a unified approach to the handling of files and sockets in PHP extension. Using a single API with standard functions for common operations, the streams API allows your extension to access files, sockets, URLs, memory and script-defined objects. Streams is a run-time extensible API that allows dynamically loaded modules (and scripts!) to register new streams. </P ><P > The aim of the Streams API is to make it comfortable for developers to open files, urls and other streamable data sources with a unified API that is easy to understand. The API is more or less based on the ANSI C stdio family of functions (with identical semantics for most of the main functions), so C programmers will have a feeling of familiarity with streams. </P ><P > The streams API operates on a couple of different levels: at the base level, the API defines php_stream objects to represent streamable data sources. On a slightly higher level, the API defines php_stream_wrapper objects which "wrap" around the lower level API to provide support for retrieving data and meta-data from URLs. </P ><P > Streams can be cast (converted) into other types of file-handles, so that they can be used with third-party libraries without a great deal of trouble. This allows those libraries to access data directly from URL sources. If your system has the <B CLASS="function" >fopencookie()</B > or <B CLASS="function" >funopen()</B > function, you can even pass any PHP stream to any library that uses ANSI stdio! </P ><P > <DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > The functions in this chapter are for use in the PHP source code and are not PHP functions. Userland stream functions can be found in the <A HREF="ref.stream.html" >Stream Reference</A >. </P ></BLOCKQUOTE ></DIV > </P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="zend.api-macros.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="streams.basics.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >API Macros</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Streams Basics</TD ></TR ></TABLE ></DIV ></BODY ></HTML >