fopen
$fp = fopen("download.php","rb");
while(!feof($fp)){
echo "fopen: ".fgets($fp);
}
fclose($fp);
说明:
对于fgets($handle,$length);
fgets是读取一行,返回$length-1长度的数据。
fgetc($handle)是读一个字节。
file
$lines = file("download.php");
foreach($lines as $line){
echo "file: ".$line;
}
file_get_contents
$content = file_get_contents("download.php");
echo "get_contents: ".$content;
readfile
echo "readfile: ";
readfile("download.php");
flush();
据说readfile,file_get_contents开启内存映射是不占php线程本身内存的。