<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Opens file or URL</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="streamwrapper.stream-metadata.html">streamWrapper::stream_metadata</a></div> <div class="next" style="text-align: right; float: right;"><a href="streamwrapper.stream-read.html">streamWrapper::stream_read</a></div> <div class="up"><a href="class.streamwrapper.html">streamWrapper</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="streamwrapper.stream-open" class="refentry"> <div class="refnamediv"> <h1 class="refname">streamWrapper::stream_open</h1> <p class="verinfo">(PHP 4 >= 4.3.2, PHP 5)</p><p class="refpurpose"><span class="refname">streamWrapper::stream_open</span> — <span class="dc-title">Opens file or URL</span></p> </div> <div class="refsect1 description" id="refsect1-streamwrapper.stream-open-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>streamWrapper::stream_open</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter">$mode</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$opened_path</code></span> )</div> <p class="para rdfs-comment"> This method is called immediately after the wrapper is initialized (f.e. by <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span> and <span class="function"><a href="function.file-get-contents.html" class="function">file_get_contents()</a></span>). </p> </div> <div class="refsect1 parameters" id="refsect1-streamwrapper.stream-open-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">path</code></em></span> <dd> <p class="para"> Specifies the URL that was passed to the original function. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> The URL can be broken apart with <span class="function"><a href="function.parse-url.html" class="function">parse_url()</a></span>. Note that only URLs delimited by :// are supported. : and :/ while technically valid URLs, are not. </p> </p></blockquote> </dd> </dt> <dt> <span class="term"><em><code class="parameter">mode</code></em></span> <dd> <p class="para"> The mode used to open the file, as detailed for <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span>. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Remember to check if the <em><code class="parameter">mode</code></em> is valid for the <em><code class="parameter">path</code></em> requested. </p> </p></blockquote> </dd> </dt> <dt> <span class="term"><em><code class="parameter">options</code></em></span> <dd> <p class="para"> Holds additional flags set by the streams API. It can hold one or more of the following values OR'd together. <table class="doctable informaltable"> <thead> <tr> <th>Flag</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td><strong><code>STREAM_USE_PATH</code></strong></td> <td>If <em><code class="parameter">path</code></em> is relative, search for the resource using the include_path. </td> </tr> <tr> <td><strong><code>STREAM_REPORT_ERRORS</code></strong></td> <td>If this flag is set, you are responsible for raising errors using <span class="function"><a href="function.trigger-error.html" class="function">trigger_error()</a></span> during opening of the stream. If this flag is not set, you should not raise any errors. </td> </tr> </tbody> </table> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">opened_path</code></em></span> <dd> <p class="para"> If the <em><code class="parameter">path</code></em> is opened successfully, and <strong><code>STREAM_USE_PATH</code></strong> is set in <em><code class="parameter">options</code></em>, <em><code class="parameter">opened_path</code></em> should be set to the full path of the file/resource that was actually opened. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-streamwrapper.stream-open-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 errors" id="refsect1-streamwrapper.stream-open-errors"> <h3 class="title">Errors/Exceptions</h3> <p class="para">Emits <strong><code>E_WARNING</code></strong> if call to this method fails (i.e. not implemented).</p> </div> <div class="refsect1 notes" id="refsect1-streamwrapper.stream-open-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">The <var class="varname"><var class="varname">streamWrapper::$context</var></var> property is updated if a valid context is passed to the caller function.</p></p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-streamwrapper.stream-open-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.fopen.html" class="function" rel="rdfs-seeAlso">fopen()</a> - Opens file or URL</span></li> <li class="member"> <span class="function"><a href="function.parse-url.html" class="function" rel="rdfs-seeAlso">parse_url()</a> - Parse a URL and return its components</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="streamwrapper.stream-metadata.html">streamWrapper::stream_metadata</a></div> <div class="next" style="text-align: right; float: right;"><a href="streamwrapper.stream-read.html">streamWrapper::stream_read</a></div> <div class="up"><a href="class.streamwrapper.html">streamWrapper</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>