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'