分解它:
function get_text($filename) { //Defines the function, taking one argument - Filename, a string.
$fp_load = fopen("$filename", "rb"); //Opens the file, with "read binary" mode.
if ( $fp_load ) { // If it's loaded - fopen() returns false on failure
while ( !feof($fp_load) ) { //Loop through, while feof() == false- feof() is returning true when finding a End-Of-File pointer
$content .= fgets($fp_load, 8192); // appends the following 8192 bits (or newline, or EOF.)
} //Ends the loop - obviously.
fclose($fp_load); //Closes the stream, to the file.
return $content; //returns the content of the file, as appended and created in the loop.
} // ends if
} //ends function
我希望这有帮助。
详细说明8192:
当读取到 length - 1 个字节、换行符(包含在返回值中)或 EOF(以先到者为准)时,读取结束。如果没有指定长度,它将继续从流中读取,直到到达行尾。
来自: http: //php.net/manual/en/function.fgets.php