Is there a way I can echo the whole content of a .html file in PHP?
For example, I have some sample.html file, and I want to echo that filename, so its content should be displayed.
You should use readfile()
:
readfile("/path/to/file");
This will read the file and send it to the browser in one command. This is essentially the same as:
echo file_get_contents("/path/to/file");
except that file_get_contents()
may cause the script to crash for large files, while readfile()
won't.