mirror of
https://github.com/php/doc-ru.git
synced 2026-03-26 00:32:15 +01:00
142 lines
4.5 KiB
XML
142 lines
4.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: 29cf1ea0ec2d4ee04f723da66461a2f613e0876f Maintainer: mch Status: ready -->
|
||
<!-- Reviewed: no -->
|
||
<refentry xml:id="function.stream-context-create" xmlns="http://docbook.org/ns/docbook">
|
||
<refnamediv>
|
||
<refname>stream_context_create</refname>
|
||
<refpurpose>Создаёт контекст потока</refpurpose>
|
||
</refnamediv>
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<methodsynopsis>
|
||
<type>resource</type><methodname>stream_context_create</methodname>
|
||
<methodparam choice="opt"><type class="union"><type>array</type><type>null</type></type><parameter>options</parameter><initializer>&null;</initializer></methodparam>
|
||
<methodparam choice="opt"><type class="union"><type>array</type><type>null</type></type><parameter>params</parameter><initializer>&null;</initializer></methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
Создаёт и возвращает контекст потока с опциями, указанными в массиве
|
||
<parameter>options</parameter>.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
<para>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term><parameter>options</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Должен быть ассоциативным массивом в формате
|
||
<literal>$arr['wrapper']['option'] = $value</literal> или &null;. Список доступных обёрток
|
||
и опций смотрите в разделе <link linkend="context">Опции контекста</link>
|
||
</para>
|
||
<para>
|
||
Значение по умолчанию - &null;.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term><parameter>params</parameter></term>
|
||
<listitem>
|
||
<para>
|
||
Требуется ассоциативный массив в формате
|
||
<literal>$arr['parameter'] = $value</literal> или &null;.
|
||
Список стандартных параметров потока
|
||
приводит раздел «<link linkend="context.params">Параметры контекста</link>».
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
Ресурс (<type>resource</type>) контекста потока.
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="changelog">
|
||
&reftitle.changelog;
|
||
<informaltable>
|
||
<tgroup cols="2">
|
||
<thead>
|
||
<row>
|
||
<entry>&Version;</entry>
|
||
<entry>&Description;</entry>
|
||
</row>
|
||
</thead>
|
||
<tbody>
|
||
<row>
|
||
<entry>8.0.0</entry>
|
||
<entry>
|
||
Параметры <parameter>options</parameter> и <parameter>params</parameter> теперь принимают значение null.
|
||
</entry>
|
||
</row>
|
||
</tbody>
|
||
</tgroup>
|
||
</informaltable>
|
||
</refsect1>
|
||
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<example>
|
||
<title>Пример использования функции <function>stream_context_create</function></title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
|
||
$opts = [
|
||
'http' => [
|
||
'method' => "GET",
|
||
// Указываем символ новой строки \n, чтобы разделить заголовки
|
||
'header' => "Accept-language: en\nCookie: foo=bar",
|
||
]
|
||
];
|
||
|
||
$context = stream_context_create($opts);
|
||
|
||
/* Отправляет HTTP-запрос на домен www.example.com
|
||
с дополнительными заголовкам, показанными выше */
|
||
$fp = fopen('http://www.example.com', 'r', false, $context);
|
||
fpassthru($fp);
|
||
fclose($fp);
|
||
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</example>
|
||
</refsect1>
|
||
|
||
<refsect1 role="seealso">
|
||
&reftitle.seealso;
|
||
<simplelist>
|
||
<member><function>stream_context_set_option</function></member>
|
||
<member>Список поддерживаемых обёрток (<xref linkend="wrappers"/>)</member>
|
||
<member>Опции контекста (<xref linkend="context"/>)</member>
|
||
</simplelist>
|
||
</refsect1>
|
||
</refentry>
|
||
<!-- Keep this comment at the end of the file
|
||
Local variables:
|
||
mode: sgml
|
||
sgml-omittag:t
|
||
sgml-shorttag:t
|
||
sgml-minimize-attributes:nil
|
||
sgml-always-quote-attributes:t
|
||
sgml-indent-step:1
|
||
sgml-indent-data:t
|
||
indent-tabs-mode:nil
|
||
sgml-parent-document:nil
|
||
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||
sgml-exposed-tags:nil
|
||
sgml-local-catalogs:nil
|
||
sgml-local-ecat-files:nil
|
||
End:
|
||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
vim: et tw=78 syn=sgml
|
||
vi: ts=1 sw=1
|
||
-->
|