Read content of a file to string (in this example, we echo it):
将文件的内容读取为字符串 (在此示例中,我们将其回显):
// Get text from file
function get_text($text_filename) {
if ($text_filename != "") {
$text = "";
$text_file = fopen($text_filename, "r");
while (!feof($text_file)) {
$text = $text . fgets($text_file, 4096);
}
fclose($text_file);
if ( $text != "" ) {
echo $text;
}
}
}
翻译自: https://www.systutorials.com/how-to-read-file-to-string-in-php/