时间:2021-10-02加入收藏
function file_get_contents_post($url, $post){
$options = array(
'http'=> array(
'method'=>'POST',
'content'=> http_build_query($post),
),
);
$result = file_get_contents($url,false, stream_context_create($options));
return $result;
}
$data = file_get_contents_post("http://xxx.xxx.xx/post.php",
array('name'=>'caiknife','email'=>'[email protected]'));
var_dump($data);
function curl_post($url, $post){
$options = array(
CURLOPT_RETURNTRANSFER =>true,
CURLOPT_HEADER =>false,
CURLOPT_POST =>true,
CURLOPT_POSTFIELDS => $post,
);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$data = curl_post("http://www.a.com/post/post.php",
array('name'=>'caiknife','email'=>'caiknife#gmail.com'));
var_dump($data);