如果您的PHP服务器允许使用url fopen包装器,那么最简单的方法是:
$html = file_get_contents('http://stackoverflow.com/questions/ask');
如果需要更多控制,则应查看cURL函数:
$c = curl_init('http://stackoverflow.com/questions/ask');
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
//curl_setopt(... other options you want...)
$html = curl_exec($c);
if (curl_error($c))
die(curl_error($c));
// Get the status code
$status = curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);