Signatur
stream_context_create(?array $options = null, ?array $params = null): resource
Beschreibung
Options sind nach Wrapper geschachtelt: ['http' => [...], 'ssl' => [...]].
Parameter
| Name | Typ | Default | Beschreibung |
|---|---|---|---|
| $options | ?array | null | Wrapper-Optionen. |
| $params | ?array | null | Weitere Parameter. |
Rückgabewert
Typ
resource
Beschreibung
Context-Handle.
Beispiele
HTTP mit Timeout und Headers
<?php
$ctx = stream_context_create([
'http' => [
'timeout' => 5,
'header' => "Accept: application/json\r\nUser-Agent: programmierung.net\r\n",
'method' => 'GET',
],
]);
$json = file_get_contents($url, context: $ctx);