How to Read File into String in PHP
Posted on In WebRead 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; } } }