mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Include example usage of stream contexts
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@122802 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
b4ed63889a
commit
86457fbefb
1 changed files with 35 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.stream-context-create">
|
||||
<refnamediv>
|
||||
<refname>stream_context_create</refname>
|
||||
|
@ -9,15 +9,45 @@
|
|||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>resource</type><methodname>stream_context_create</methodname>
|
||||
<methodparam><type>array</type><parameter>params</parameter></methodparam>
|
||||
<methodparam><type>array</type><parameter>options</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<simpara>
|
||||
Creates and returns a stream context with any parameters supplied in
|
||||
<parameter>params</parameter> preset.
|
||||
Creates and returns a stream context with any options supplied in
|
||||
<parameter>options</parameter> preset.
|
||||
</simpara>
|
||||
<simpara>
|
||||
<parameter>options</parameter> must be an associative
|
||||
array of associative arrays in the format
|
||||
<literal>$arr['wrapper']['option'] = $value</literal>.
|
||||
</simpara>
|
||||
<example>
|
||||
<title>Using <function>stream_context_create</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$opts = array(
|
||||
'http'=>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);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<simpara>
|
||||
See Also:
|
||||
<function>stream_context_set_params</function>
|
||||
<function>stream_context_set_option</function>, and
|
||||
Listing of supported wrappers with context options (<xref linkend="wrappers"/>)
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
|
Loading…
Reference in a new issue