使用file_ get_contents()进行post请求

$url = "http://localhost/test/test.php";
$data=array('author '=> 'szy','intro'=> '哎呦,错了');

$data=http_build_query ($data);

$opts = array(
    'http' => array(
        'method' => 'POST',
        'heade' => "Content-type:application/x-www-form-urlencoded Content-Length:".strlen ($data),
        'content' =>$data
    )
);

$context = stream_context_create($opts);
$html = file_get_contents($url,false,$context);
print_r($html);

 

你可能感兴趣的:(php)