?php #判斷文件類型是:文件 $file= img/meinv.jpg echo filetype($file);?
?php #判斷文件類型是:目錄 $file= img echo filetype($file);?
?php #判斷到底是不是文件:是 $file= img/meinv.jpg echo is_file($file);?
?php #判斷到底是否存在:是 $file= img/meinv.jpg $b=file_exists($file); var_dump($b);?
?php #獲取文件大小M $file= img/meinv.jpg $b=filesize($file); var_dump($b);?
?php #讀取三個字節 $file= ./a.txt $fp=fopen($file, r $str=fread($fp,3); echo $str;?
?php #讀取三個字節 $file= ./a.txt $fp=fopen($file, r $str=fread($fp,6);#換行的時候隱藏了個/n(占據兩個字節) echo $str;?
?php #獲取文件里所有東西 $file= a.txt $size=filesize($file); $fp=fopen($file, r $str=fread($fp, $size); echo $str;?
?php $file= b.txt $fp=fopen($file, w #生成一個b.txt文件 a:追加文本,w重新寫 $str= aa1 br bb br cc br fwrite($fp,$str);#往文件里寫入字符串?
?php $file= b.txt unlink($file);#刪除文件函數?
?php $sfile= a.txt $dfile= aaa.txt rename($sfile,$dfile);#文件重命名?
?php $sfile= aaa.txt $dfile= ccc.txt copy($sfile, $dfile);#文件復制函數?
?php $sfile= aaa.txt $dfile= ddd.txt copy($sfile, $dfile);#文件復制函數 #把源文件刪除了整合一下就是復制 #后把源文件刪除就是移動 unlink($sfile);?
?php $sfile= ccc.txt readfile($sfile);#直接讀取文件里內容并輸出函數?
?php $sfile= ccc.txt $str=file_get_contents($sfile);#只是讀取不輸出?
?php $sfile= http://www.baidu.com $str=file_get_contents($sfile);#只是讀取不輸出 echo $str; #把讀取的百度網址輸出,呈現百度界面?
?php $sfile= http://www.baidu.com $str=file_get_contents($sfile);#只是讀取不輸出 $ptn= / title (.+) //title / #正則匹配采集條件 preg_match($ptn,$str,$arr);#采集函數 echo pre print_r($arr);#輸出采集內容 echo /pre ?
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答