問題 :創建一個http請求。
<?php
function send_post($url,$data){
$data = http_build_query($data);
$options = array(
'http'=>array(
'method'=>'POST',
'header'=>'Content-type:application/x-www-form-urlencoded',
'content'=>$data,
'timeout'=> 60,//s
)
);
$context = stream_context_create($options);
打開文件第一種:
$result = file_get_contents($url,false,$context);
打開文件第二種:
$fp = fopen($url,'r',false,$context);
fpassthru($fp); //函數輸出文件指針處的所有剩余數據。該函數將給定的文件指針從當前的位置讀取到 EOF,并把結果寫到輸出緩沖區。
fclose($fp);
}
<?php
$file = fopen("test.txt","r");
//改變文件指針的位置 15
fseek($file,"15");
//把文件指針設定為 0 函數將文件指針的位置倒回文件的開頭。
rewind($file);
fclose($file);
?>