1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHP POSTで受信

Posted at
page1.php
<?php
echo "page1";
$postdata = http_build_query(
    array(
        'data1' => 'hello',
        'data2' => 'world'
    )
);

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context  = stream_context_create($opts);

$result = file_get_contents('page2.php', false, $context);
var_dump($result);
page2.php
<?php
echo "page2";
var_dump($_POST);

page2から$_POSTで受け取ったデータを見るとdata1(hello)とdata2(world)が
あることが分かります。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?