您好,欢迎访问一九零五行业门户网

php发送post的问题

post.php向getpost.php发送post
getpost.php里面只有这句 var_dump($_post);
为什么getpost.php里面是空 反而post.php里面得到了值。
谢谢了
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);

回复内容: post.php向getpost.php发送post
getpost.php里面只有这句 var_dump($_post);
为什么getpost.php里面是空 反而post.php里面得到了值。
谢谢了
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请加上'header' => 'content-type:application/x-www-form-urlencoded'
其它类似信息

推荐信息