php中几个文件读取函数的贴心功能
- <?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