file_get_contents($url) stream_get_contents($stream)

来源:互联网 发布:java web完整项目源码 编辑:程序博客网 时间:2024/05/29 15:28

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> get_contents.php </title>
  <meta charset="UTF-8">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
 </head>

 <body>
<hr>
<?php
$url='http://localhost/myphp/StrPrice.html';
$contents=file_get_contents($url) or die('file_get_contents failed!');
var_dump($contents);


$stream=fopen($url,'rb');
$contents=stream_get_contents($stream) or die('stream_get_contents failed!');
var_dump($contents);
fclose($stream);



$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
$result = curl_exec($ch);
var_dump($result);
?>

<br><br>

 </body>
</html>


0 0
原创粉丝点击