Post sending in php

Source: Internet
Author: User
Post. php sends postgetPost. php to getPost. php, which only contains this var_dump ($ _ POST). Why is it empty in getPost. php? Instead, it gets a value in post. php. Thanks {code...} post. php for sending post to getPost. php
GetPost. php only contains this var_dump ($ _ POST );
Why is it null in getPost. php? Instead, the value is obtained in post. php.
Thank you.

function do_post_request($url, $data, $optional_headers = null){    $params = array('http' => array(        'method' => 'POST',        'content' => $data    ));    if ($optional_headers !== null) {        $params['http']['header'] = $optional_headers;    }    $ctx = stream_context_create($params);    $fp = @fopen($url, 'rb', false, $ctx);    if (!$fp) {        throw new Exception("Problem with $url, $php_errormsg");    }    $response = @stream_get_contents($fp);    if ($response === false) {        throw new Exception("Problem reading data from $url, $php_errormsg");    }    return $response;}$postdata = array('name' => 'lichen');$postdata = http_build_query($postdata);echo do_post_request('http://localhost/getPost.php', $postdata);

Reply content:

Post. php sends post to getPost. php
GetPost. php only contains this var_dump ($ _ POST );
Why is it null in getPost. php? Instead, the value is obtained in post. php.
Thank you.

function do_post_request($url, $data, $optional_headers = null){    $params = array('http' => array(        'method' => 'POST',        'content' => $data    ));    if ($optional_headers !== null) {        $params['http']['header'] = $optional_headers;    }    $ctx = stream_context_create($params);    $fp = @fopen($url, 'rb', false, $ctx);    if (!$fp) {        throw new Exception("Problem with $url, $php_errormsg");    }    $response = @stream_get_contents($fp);    if ($response === false) {        throw new Exception("Problem reading data from $url, $php_errormsg");    }    return $response;}$postdata = array('name' => 'lichen');$postdata = http_build_query($postdata);echo do_post_request('http://localhost/getPost.php', $postdata);

$ Param add 'head' => 'content-type: application/x-www-form-urlencoded'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.