File tree Expand file tree Collapse file tree 3 files changed +46
-9
lines changed Expand file tree Collapse file tree 3 files changed +46
-9
lines changed Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<!-- $Revision$ -->
3
- <!-- EN-Revision: cdaea0421544885f02ff3d36bd203dc01b78299e Maintainer: satoruyoshida Status: ready -->
3
+ <!-- EN-Revision: f56de7ebe7a1a85ce9e44a2bf6b77b07adfe3ae4 Maintainer: satoruyoshida Status: ready -->
4
4
<!-- CREDITS: mumumu -->
5
5
6
6
<refentry role =" variable" xml : id =" reserved.variables.get" xmlns =" http://docbook.org/ns/docbook" xmlns : xlink =" http://www.w3.org/1999/xlink" >
7
7
<refnamediv >
8
8
<refname >$_GET</refname >
9
- <refpurpose >HTTP GET 変数 </refpurpose >
9
+ <refpurpose >クエリストリング変数 </refpurpose >
10
10
</refnamediv >
11
11
12
12
<refsect1 role =" description" >
13
13
&reftitle.description;
14
14
<para >
15
15
URL パラメータ (a.k.a クエリストリング) で現在のスクリプトに渡された変数の連想配列です。
16
- この配列の値は、GETリクエストだけでなく 、クエリストリングが含まれた全てのリクエストで収集されることに注意して下さい。
16
+ この配列の値は、HTTP リクエストメソッドに関係なく 、クエリストリングが含まれた全てのリクエストで収集されることに注意して下さい。
17
17
</para >
18
18
19
19
</refsect1 >
@@ -31,7 +31,7 @@ echo 'Hello ' . htmlspecialchars($_GET["name"]) . '!';
31
31
]]>
32
32
</programlisting >
33
33
<simpara >
34
- ユーザーが http://example.com/?name=Hannes と入力したとします。
34
+ ユーザーが < literal > http://example.com/?name=Hannes</ literal > と入力したとします。
35
35
</simpara >
36
36
&example.outputs.similar;
37
37
<screen >
@@ -48,7 +48,7 @@ Hello Hannes!
48
48
¬e.is-superglobal;
49
49
<note >
50
50
<para >
51
- GET 変数は <function >urldecode</function > 関数を介して渡されます 。
51
+ < varname >$_GET</ varname > の値は <function >urldecode</function > 関数を介して自動的に渡されます 。
52
52
</para >
53
53
</note >
54
54
</refsect1 >
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<!-- $Revision$ -->
3
- <!-- EN-Revision: cdaea0421544885f02ff3d36bd203dc01b78299e Maintainer: takagi Status: ready -->
3
+ <!-- EN-Revision: f56de7ebe7a1a85ce9e44a2bf6b77b07adfe3ae4 Maintainer: takagi Status: ready -->
4
4
<!-- Credits: mumumu -->
5
5
6
6
<refentry role =" variable" xml : id =" reserved.variables.post" xmlns =" http://docbook.org/ns/docbook" xmlns : xlink =" http://www.w3.org/1999/xlink" >
7
7
<refnamediv >
8
8
<refname >$_POST</refname >
9
- <refpurpose >HTTP POST 変数 </refpurpose >
9
+ <refpurpose >HTTP POST リクエストから得られるフォームデータ </refpurpose >
10
10
</refnamediv >
11
11
12
12
<refsect1 role =" description" >
@@ -32,7 +32,8 @@ echo 'Hello ' . htmlspecialchars($_POST["name"]) . '!';
32
32
]]>
33
33
</programlisting >
34
34
<simpara >
35
- ユーザーが name=Hannes と POST したとします。
35
+ ユーザーがリクエストボディに <literal >name=Hannes</literal >
36
+ を付けて POST リクエストを送信したとします。
36
37
</simpara >
37
38
&example.outputs.similar;
38
39
<screen >
@@ -47,6 +48,20 @@ Hello Hannes!
47
48
<refsect1 role =" notes" >
48
49
&reftitle.notes;
49
50
¬e.is-superglobal;
51
+ <note >
52
+ <simpara >
53
+ その他の content type
54
+ (例: <literal >application/json</literal > や
55
+ <literal >application/xml</literal >)
56
+ を指定して送信された POST データを読み取るには、
57
+ <link linkend =" wrappers.php.input" ><filename >php://input</filename ></link >
58
+ を使わなければいけません。
59
+ <literal >application/x-www-form-urlencoded</literal > と
60
+ <literal >multipart/form-data</literal > を指定した場合にだけ動作する
61
+ <varname >$_POST</varname > とは異なり、
62
+ <filename >php://input</filename > はリクエストボディの生データに直接アクセスします。
63
+ </simpara >
64
+ </note >
50
65
</refsect1 >
51
66
52
67
<refsect1 role =" seealso" >
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<!-- $Revision$ -->
3
- <!-- EN-Revision: 0592e6316d3869b49637df29c471097e7bf78592 Maintainer: takagi Status: ready -->
3
+ <!-- EN-Revision: f56de7ebe7a1a85ce9e44a2bf6b77b07adfe3ae4 Maintainer: takagi Status: ready -->
4
4
<!-- CREDITS: hirokawa,mumumu -->
5
5
6
6
<refentry xml : id =" wrappers.php" xmlns =" http://docbook.org/ns/docbook" xmlns : xlink =" http://www.w3.org/1999/xlink" annotations =" verify_info:false" role =" stream_wrapper" >
@@ -363,6 +363,28 @@ file_put_contents("php://filter/write=string.rot13/resource=example.txt","Hello
363
363
<?php
364
364
file_put_contents('php://memory', 'PHP');
365
365
echo file_get_contents('php://memory'); // 何も表示されません
366
+ ]]>
367
+ </programlisting >
368
+ </example >
369
+ <example >
370
+ <title >リクエストボディから、JSON データを読み取るために php://input を使う</title >
371
+ <para >
372
+ この例は、<filename >php://input</filename > を使って POST, PUT,
373
+ PATCH リクエスト経由で生の JSON データを読み取る方法を示します。
374
+ </para >
375
+ <programlisting role =" php" >
376
+ <![CDATA[
377
+ <?php
378
+ $input = file_get_contents("php://input");
379
+ $json_array = json_decode(
380
+ json: $input,
381
+ associative: true,
382
+ flags: JSON_THROW_ON_ERROR
383
+ );
384
+
385
+ echo "Received JSON data: ";
386
+ print_r($json_array);
387
+ ?>
366
388
]]>
367
389
</programlisting >
368
390
</example >
You can’t perform that action at this time.
0 commit comments