您的位置:首页 > 编程语言 > PHP开发

php中几个文件读取函数的贴心功能

2009-08-31 17:07 399 查看
<?php
$html = file_get_contents('http://www.example.com/');
print_r($http_response_header);

// or
$fp = fopen('http://www.example.com/', 'r');
print_r(stream_get_meta_data($fp));
fclose($fp);
?>

示例代码2:

<?php
$data = array ('foo' => 'bar');
$data = http_build_query($data);

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

$context = stream_context_create($opts);
$html = file_get_contents('http://www.example.com', false, $context);

echo $html;
?>
from:http://www.ugia.cn/?p=140
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: