Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 12654

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>Accessing HTTP(s) URLs</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="wrappers.file.html">file://</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="wrappers.ftp.html">ftp://</a></div>
 <div class="up"><a href="wrappers.html">Supported Protocols and Wrappers</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="wrappers.http" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">http://</h1>
  <h1 class="refname">https://</h1>
  <p class="refpurpose"><span class="refname">http://</span> -- <span class="refname">https://</span> &mdash; <span class="dc-title">Accessing HTTP(s) URLs</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-wrappers.http-description">
  <h3 class="title">Description</h3>
  <p class="para">
   Allows read-only access to files/resources via HTTP 1.0,
   using the HTTP GET method. A <em>Host:</em> header is sent with the request
   to handle name-based virtual hosts.  If you have configured
   a <a href="filesystem.configuration.html#ini.user-agent" class="link">user_agent</a> string using
   your <var class="filename">php.ini</var> file or the stream context, it will also be included
   in the request.
  </p>
  <p class="simpara">
   The stream allows access to the <em class="emphasis">body</em> of
   the resource; the headers are stored in the
   <var class="varname"><var class="varname"><a href="reserved.variables.httpresponseheader.html" class="classname">$http_response_header</a></var></var> variable.
  </p>
  <p class="simpara">
   If it&#039;s important to know the URL of the resource where
   your document came from (after all redirects have been processed),
   you&#039;ll need to process the series of response headers returned by the
   stream.
  </p>
  <p class="simpara">
   The <a href="filesystem.configuration.html#ini.from" class="link">from</a> directive will be used for the
   <em>From:</em> header if set and not overwritten by the
   <a href="context.html" class="xref">Context options and parameters</a>.
  </p>
 </div>


 <div class="refsect1 usage" id="refsect1-wrappers.http-usage"> 
  <h3 class="title">Usage</h3>
  <ul class="itemizedlist">
   <li class="listitem"><span class="simpara"><var class="filename">http://example.com</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">http://example.com/file.php?var1=val1&amp;var2=val2</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">http://user:password@example.com</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">https://example.com</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">https://example.com/file.php?var1=val1&amp;var2=val2</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">https://user:password@example.com</var></span></li>
  </ul>
 </div>
 

 <div class="refsect1 options" id="refsect1-wrappers.http-options">
  <h3 class="title">Options</h3>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Wrapper Summary</strong></caption>
    
     <thead>
      <tr>
       <th>Attribute</th>
       <th>Supported</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>Restricted by <a href="filesystem.configuration.html#ini.allow-url-fopen" class="link">allow_url_fopen</a></td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>Allows Reading</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>Allows Writing</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Allows Appending</td>
       <td>No</td>
      </tr>

      <tr>
       <td>Allows Simultaneous Reading and Writing</td>
       <td>N/A</td>
      </tr>

      <tr>
       <td>Supports  <span class="function"><a href="function.stat.html" class="function">stat()</a></span></td>
       <td>No</td>
      </tr>

      <tr>
       <td>Supports  <span class="function"><a href="function.unlink.html" class="function">unlink()</a></span></td>
       <td>No</td>
      </tr>

      <tr>
       <td>Supports  <span class="function"><a href="function.rename.html" class="function">rename()</a></span></td>
       <td>No</td>
      </tr>

      <tr>
       <td>Supports  <span class="function"><a href="function.mkdir.html" class="function">mkdir()</a></span></td>
       <td>No</td>
      </tr>

      <tr>
       <td>Supports  <span class="function"><a href="function.rmdir.html" class="function">rmdir()</a></span></td>
       <td>No</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>
 

 <div class="refsect1 changelog" id="refsect1-wrappers.http-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.3.7</td>
       <td>
        Detect buggy IIS servers to avoid <em>&quot;SSL: Fatal Protocol Error&quot;</em> errors.
       </td>
      </tr>

      <tr>
       <td>4.3.0</td>
       <td>
        Added <em>https://</em>.
       </td>
      </tr>

      <tr>
       <td>4.0.5</td>
       <td>
        Added support for redirects.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-wrappers.http-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="wrappers.http.example.basic">
   <p><strong>Example #1 Detecting which URL we ended up on after redirects</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$url&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'http://www.example.com/redirecting_page.php'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$url</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$meta_data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stream_get_meta_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$meta_data</span><span style="color: #007700">[</span><span style="color: #DD0000">'wrapper_data'</span><span style="color: #007700">]&nbsp;as&nbsp;</span><span style="color: #0000BB">$response</span><span style="color: #007700">)&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Were&nbsp;we&nbsp;redirected?&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">strtolower</span><span style="color: #007700">(</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$response</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">))&nbsp;==&nbsp;</span><span style="color: #DD0000">'location:&nbsp;'</span><span style="color: #007700">)&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;update&nbsp;$url&nbsp;with&nbsp;where&nbsp;we&nbsp;were&nbsp;redirected&nbsp;to&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$url&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$response</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 notes" id="refsect1-wrappers.http-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    HTTPS is only supported when the <a href="book.openssl.html" class="link">openssl</a>
    extension is enabled.
   </span>
  </p></blockquote>
  <p class="simpara">
   HTTP connections are read-only; writing data or copying
   files to an HTTP resource is not supported.
  </p>
  <p class="simpara">
   Sending <em class="emphasis">POST</em> and <em class="emphasis">PUT</em> requests, for example,
   can be done with the help of <a href="context.http.html" class="link">HTTP Contexts</a>.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-wrappers.http-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><a href="context.http.html" class="xref">HTTP context options</a></li>
   <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.httpresponseheader.html" class="classname">$http_response_header</a></var></var></li>
   <li class="member"> <span class="function"><a href="function.stream-get-meta-data.html" class="function" rel="rdfs-seeAlso">stream_get_meta_data()</a> - Retrieves header/meta data from streams/file pointers</span></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="wrappers.file.html">file://</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="wrappers.ftp.html">ftp://</a></div>
 <div class="up"><a href="wrappers.html">Supported Protocols and Wrappers</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>