本文介绍了如何在PHP中回显.html文件的全部内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以在PHP中回显.html文件的全部内容吗?
例如,我有一些sample.html文件,我想回显这个文件名,所以它的内容应该显示出来。 使用 readfile() :
readfile(/ path / to / file);这将读取文件并通过一个命令将其发送到浏览器。这与本质上相同:
echo file_get_contents(/ path / to / file);除 file_get_contents() 可能导致脚本崩溃以查找大文件,而 readfile()获胜't。
Is there any way I can echo the whole content of an .html file in php?
For e.g. 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.
更多推荐
如何在PHP中回显.html文件的全部内容?
发布评论