复制代码 代码如下:
$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>60,
) );
$context = stream_context_create($opts);$html =file_get_contents('http://www.example.com', false, $context);
复制代码 代码如下:
function Post($url, $post = null)
{
$context = array();
if (is_array($post)) {
ksort($post);
$context['http'] = array (
'timeout'=>60,
'method' => 'POST',
'content' => http_build_query($post, '', '&'),
);
}
return file_get_contents($url, false, stream_context_create($context));
}
$data = array (
'name' => 'test',
'email' => 'test@gmail.com',
'submit' => 'submit',
);
echo Post('http://www.example.com', $data);
新闻热点
疑难解答