<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.stream.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.stream-context-create.php',
    1 => 'stream_context_create',
    2 => 'Creates a stream context',
  ),
  'up' => 
  array (
    0 => 'ref.stream.php',
    1 => 'Stream-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.stream-bucket-prepend.php',
    1 => 'stream_bucket_prepend',
  ),
  'next' => 
  array (
    0 => 'function.stream-context-get-default.php',
    1 => 'stream_context_get_default',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/stream/functions/stream-context-create.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.stream-context-create" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_context_create</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stream_context_create</span> &mdash; <span class="dc-title">Creates a stream context</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-context-create-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stream_context_create</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$params</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span></div>

  <p class="para rdfs-comment">
   Creates and returns a stream context with any options supplied in
   <code class="parameter">options</code> preset.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-context-create-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       Must be an associative array of associative arrays in the format
       <code class="literal">$arr[&#039;wrapper&#039;][&#039;option&#039;] = $value</code>, or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>. Refer to <a href="context.php" class="link">context options</a> for a list of available wrappers and options.
      </p>
      <p class="para">
       Defaults to <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">params</code></dt>
     <dd>
      <p class="para">
       Must be an associative array in the format
       <code class="literal">$arr[&#039;parameter&#039;] = $value</code>, or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>.
       Refer to <a href="context.params.php" class="link">context parameters</a> for
       a listing of standard stream parameters.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-context-create-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   A stream context <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.stream-context-create-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">options</code> and <code class="parameter">params</code> are now nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.stream-context-create-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="example-1">
   <p><strong>Beispiel #1 Using <span class="function"><strong>stream_context_create()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$opts </span><span style="color: #007700">= [<br />  </span><span style="color: #DD0000">'http' </span><span style="color: #007700">=&gt; [<br />    </span><span style="color: #DD0000">'method' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"GET"</span><span style="color: #007700">,<br />    </span><span style="color: #FF8000">// Use CRLF \r\n to separate multiple headers<br />    </span><span style="color: #DD0000">'header' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"Accept-language: en\r\n" </span><span style="color: #007700">.<br />                </span><span style="color: #DD0000">"Cookie: foo=bar"</span><span style="color: #007700">,<br />  ]<br />];<br /><br /></span><span style="color: #0000BB">$context </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_context_create</span><span style="color: #007700">(</span><span style="color: #0000BB">$opts</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Sends an http request to www.example.com<br />   with additional headers shown above */<br /></span><span style="color: #0000BB">$fp </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.example.com'</span><span style="color: #007700">, </span><span style="color: #DD0000">'r'</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">$context</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fpassthru</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stream-context-create-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.stream-context-set-option.php" class="function" rel="rdfs-seeAlso">stream_context_set_option()</a> - Sets an option for a stream/wrapper/context</span></li>
   <li>Listing of supported wrappers (<a href="wrappers.php" class="xref">Unterst&uuml;tzte Protokolle und Wrapper</a>)</li>
   <li>Context options (<a href="context.php" class="xref">Kontextoptionen und -parameter</a>)</li>
  </ul>
 </div>

</div><?php manual_footer($setup); ?>