1. 程式人生 > >PHP 獲取頁面內容和儲存頁面內容

PHP 獲取頁面內容和儲存頁面內容

<meta charset="utf-8">  
<?php 
$url = "http://onestopweb.iteye.com/";
//file_get_contents() 把整個檔案讀入一個字串中。
$contents = file_get_contents($url);

//對 $contents 進行操作

//file_put_contents() 函式把一個字串寫入檔案中。
//該函式將返回寫入到檔案內資料的位元組數。
echo file_put_contents("demo.html",$contents);
?>

效果圖: