php请求url链接地址并接收返回值
方法1: 用file_get_contents 以get方式获取内容view plaincopyprint?
<?php
$url='http://www.domain.com/';
$html = file_get_contents($url);
echo $html;
?>
方法2: 用fopen打开url, 以get方式获取内容
view plaincopyprint?
<?php
$fp = fopen($url, 'r');
//返回请求流信息(数组:请求状态,阻塞,返回值是否为空,返回值http头等)e799bee5baa6e79fa5e98193e59b9ee7ad9431333335343337
view plaincopyprint?
stream_get_meta_data($fp);
view plaincopyprint?
while(!feof($fp)) {
$result .= fgets($fp, 1024);
}
echo "url body: $result";
fclose($fp);
?>原作者:百度知道匿名用户
页:
[1]