PHP.nl

stream_context_create

stream_context_create

Creates a stream context

resource **stream_context_create**  $options  $params

Creates and returns a stream context with any options supplied in preset. options

options Must be an associative array of associative arrays in the format , or null. Refer to for a list of available wrappers and options. $arr['wrapper']['option'] = $valuecontext options

Defaults to null.

params Must be an associative array in the format , or null. Refer to for a listing of standard stream parameters. $arr['parameter'] = $valuecontext parameters

A stream context . resource

**Voorbeeld: Using **

<?php
$opts = [
  'http' => [
    'method' => "GET",
    // Use CRLF \r\n to separate multiple headers
    'header' => "Accept-language: en\r\n" .
                "Cookie: foo=bar",
  ]
];

$context = stream_context_create($opts);

/* Sends an http request to www.example.com
   with additional headers shown above */
$fp = fopen('http://www.example.com', 'r', false, $context);
fpassthru($fp);
fclose($fp);
?>

stream_context_set_option