From 86457fbefbdba51b8686f5b945bafcc25ef62780 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Mon, 7 Apr 2003 23:32:46 +0000 Subject: [PATCH] Include example usage of stream contexts git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@122802 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../functions/stream-context-create.xml | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/reference/stream/functions/stream-context-create.xml b/reference/stream/functions/stream-context-create.xml index 0619b714d9..9ca64fd456 100644 --- a/reference/stream/functions/stream-context-create.xml +++ b/reference/stream/functions/stream-context-create.xml @@ -1,5 +1,5 @@ - + stream_context_create @@ -9,15 +9,45 @@ Description resourcestream_context_create - arrayparams + arrayoptions - Creates and returns a stream context with any parameters supplied in - params preset. + Creates and returns a stream context with any options supplied in + options preset. + + options must be an associative + array of associative arrays in the format + $arr['wrapper']['option'] = $value. + + + Using <function>stream_context_create</function> + +array( + 'method'=>"GET", + 'header'=>"Accept-language: en\r\n" . + "Cookie: foo=bar\r\n" + ) +); + +$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); +?> +]]> + + See Also: - stream_context_set_params + stream_context_set_option, and + Listing of supported wrappers with context options ()