大部分的文件函數之前已經接觸了。這裡只說幾個重要的:
resource fopen , string $mode [, bool. false [, resource$context$context] ]] ) //開啟文件,有唯讀,只寫,讀寫模式int filesize
filesize $filename ) // 取得檔案的大小int fwrite, string $string [, int $lengthint ) //寫入檔案string fread ( $handle , int
$length ) //讀取文件,可以讀取二進位檔案bool unlink $filename [, resource $context ] ) //刪除檔案更多更詳細的內容:http://php.net/簡單型:<?php
$in="tt.txt";
$fp=fopen($in,"r");
$get=fread($fp,filesize($in));
$fp=fopen("out.htm","w");
fwrite($fp,$get);
fclose($fp);
?>
<?php
$txtArray=array(array("t1.txt","fly.htm"),array("t2.txt","killer.htm"),
array("t3.txt","chamption.htm"));
foreach ($txtArray as $id=>$value){
$filename=$value[0];
$title=$value[1];
$fp=fopen($filename,"r");
$get=fread($fp,filesize($filename));
$fp=fopen($title,"w");
fwrite($fp,$get);
unlink($filename); //删除源文件
}
fclose($fp);
?>
<?php
$txtArray=array(array("t1.txt","michael jordan——飞翔.htm"),array("t2.txt","michael jordan——杀手.htm"),
array("t3.txt","michael jordan——首冠.htm"));
foreach ($txtArray as $id=>$value){
$filename=$value[0];
$title=$value[1];
$fp=fopen($filename,"r");
$get=fread($fp,filesize($filename));
$fp=fopen($title,"w");
fwrite($fp,$get);
//unlink($filename); //删除源文件
}
fclose($fp);
?>
rrreee
以上就介紹了PHP 產生HTML文件,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。