mirror of
https://github.com/php/doc-ja.git
synced 2026-03-23 22:52:11 +01:00
sync with en / fix(reference/stream): example code php5.4 array syntax
- HTTP context header3abd17e61de7b81f2c31
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: e50e79746736dbdfbabe9bd3566793b3ddf38f58 Maintainer: takagi Status: ready -->
|
||||
<!-- EN-Revision: 3abd17e61d5022d503604cc06894254e3281acf5 Maintainer: takagi Status: ready -->
|
||||
<!-- Credits: mumumu -->
|
||||
|
||||
<refentry xml:id="context.http" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="verify_info:false" role="stream_context_option">
|
||||
@@ -52,6 +52,17 @@
|
||||
よって、<parameter>follow_location</parameter> が有効になっている場合、
|
||||
<literal>Host:</literal> ヘッダを設定することはお勧めしません。
|
||||
</para>
|
||||
<para>
|
||||
文字列の値は、<literal>Key: value</literal> のペアを
|
||||
<literal>\r\n</literal> で区切ったものにすべきです。
|
||||
たとえば、
|
||||
<literal>"Content-Type: application/json\r\nConnection: close"</literal>
|
||||
のようにします。
|
||||
配列の値は、<literal>Key: value</literal> のペアのリストにすべきです。
|
||||
たとえば、
|
||||
<literal>["Content-Type: application/json", "Connection: close"]</literal>
|
||||
のようにします。
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry xml:id="context.http.user-agent">
|
||||
@@ -193,6 +204,7 @@
|
||||
</para>
|
||||
</refsect1><!-- }}} -->
|
||||
|
||||
|
||||
<refsect1 role="examples"><!-- {{{ -->
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
@@ -203,19 +215,19 @@
|
||||
<?php
|
||||
|
||||
$postdata = http_build_query(
|
||||
array(
|
||||
[
|
||||
'var1' => 'some content',
|
||||
'var2' => 'doh'
|
||||
)
|
||||
'var2' => 'doh',
|
||||
]
|
||||
);
|
||||
|
||||
$opts = array('http' =>
|
||||
array(
|
||||
$opts = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'content' => $postdata
|
||||
)
|
||||
);
|
||||
'content' => $postdata,
|
||||
]
|
||||
];
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
|
||||
@@ -235,13 +247,13 @@ $result = file_get_contents('http://example.com/submit.php', false, $context);
|
||||
|
||||
$url = "http://www.example.org/header.php";
|
||||
|
||||
$opts = array('http' =>
|
||||
array(
|
||||
'method' => 'GET',
|
||||
$opts = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'max_redirects' => '0',
|
||||
'ignore_errors' => '1'
|
||||
)
|
||||
);
|
||||
'ignore_errors' => '1',
|
||||
]
|
||||
];
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
$stream = fopen($url, 'r', false, $context);
|
||||
|
||||
Reference in New Issue
Block a user