PHP如何发送post get代码教
方法1:
$url='http://www.lenniu.com/?a=1$b=2';
$html = file_get_contents($url);
echo $html;
?>
方法2:
$data = array ('foo' => 'bar');
$data = http_build_query($data);
$opts = array (
‘http' => array (
'method' => 'POST',
'header'=> "Content-type: application/x-www-form-urlencodedrn",
"Content-Length: " . strlen($data) . "rn",
'content' => $data
)
);
$context = stream_context_create($opts);
$html = file_get_contents('http://www.lenniu.com', false, $context);
echo $html;
?>