Home > Backend Development > PHP Tutorial > php读资料的4中方法

php读资料的4中方法

WBOY
Release: 2016-06-13 10:31:24
Original
877 people have browsed it

php读文件的4中方法。
fopen

$fp = fopen("download.php","rb");	while(!feof($fp)){		echo "fopen: ".fgets($fp);	}	fclose($fp);
Copy after login


说明:
对于fgets($handle,$length);
fgets是读取一行,返回$length-1长度的数据。
fgetc($handle)是读一个字节。

file
$lines = file("download.php");	foreach($lines as $line){		echo "file: ".$line;	}
Copy after login

file_get_contents
$content = file_get_contents("download.php");echo "get_contents: ".$content;
Copy after login

readfile 据说readfile是不占php线程本身内存的。
echo "readfile: ";	readfile("download.php");	flush();
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template