1
0
mirror of https://github.com/php/doc-ru.git synced 2026-04-28 17:53:14 +02:00
Files
archived-doc-ru/reference/stream/functions/stream-context-get-default.xml
Mikhail Alferov 880e6f88f2 Update 3abd17e to En (#1093)
* Update http.xml to en

* Update file-get-contents.xml to en

* Update libxml-set-streams-context.xml to en

* Update stream-context-get-default.xml to en

* Update stream-context-set-default.xml to en

* Update xmlrpc-encode-request.xml to en
2025-07-25 16:28:46 +03:00

151 lines
4.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 3abd17e61d5022d503604cc06894254e3281acf5 Maintainer: mch Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.stream-context-get-default" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>stream_context_get_default</refname>
<refpurpose>Получает контекст потока по умолчанию</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>stream_context_get_default</methodname>
<methodparam choice="opt"><type class="union"><type>array</type><type>null</type></type><parameter>options</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<simpara>
Функция возвращает контекст потока по умолчанию, который применяют функции наподобие
<function>fopen</function>, <function>file_get_contents</function>
при вызове без параметра контекста. При вызове с необязательным аргументом
функция установит опции контекста по умолчанию. Синтаксис опций аналогичен
формату параметра <parameter>options</parameter> функции <function>stream_context_create</function>.
</simpara>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<simpara>
Параметр <parameter>options</parameter> принимает ассоциативный массив
ассоциативных массивов в формате
<literal>$arr['wrapper']['option'] = $value</literal> или &null;.
</simpara>
</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> теперь принимает значение null.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example xml:id="stream-context-get-default.example.basic">
<title>Пример получения контекста потока по умолчанию функцией <function>stream_context_get_default</function></title>
<programlisting role="php">
<![CDATA[
<?php
$default_opts = [
'http' => [
'method' => "GET",
'header' => "Accept-language: en\r\n" .
"Cookie: foo=bar",
'proxy' => "tcp://10.54.1.39:8000",
]
];
$alternate_opts = [
'http' => [
'method' => "POST",
'header' => "Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: " . strlen("baz=bomb"),
'content' => "baz=bomb",
]
];
$default = stream_context_get_default($default_opts);
$alternate = stream_context_create($alternate_opts);
/* Функция отправляет стандартный GET-запрос на прокси-сервер 10.54.1.39;
* для адреса www.example.com применяются опции контекста из массива $default_opts
*/
readfile('http://www.example.com');
/* Функция отправляет POST-запрос на адрес www.example.com;
* применяются опции контекста из массива $alternate_opts
*/
readfile('http://www.example.com', false, $alternate);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso"><!-- {{{ -->
&reftitle.seealso;
<para>
<simplelist>
<member><function>stream_context_create</function></member>
<member><function>stream_context_set_default</function></member>
<member><xref linkend="wrappers"/>: список поддерживаемых обёрток и опций контекста</member>
</simplelist>
</para>
</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
-->