大家好,我想使用 php 创建简单的文件系统。我想使用 php 显示上传文件的内容。但是,当我上传 html 或 php 文件时,将执行 html 或 php 代码,而不是显示其内容。我想显示该文件而不执行。请帮助我。谢谢。
最佳答案
如果 PHP get 被执行,您将包含/需要该文件。请阅读其内容,例如与 file_get_contents()
要阻止浏览器解析 HTML,请使用 htmlentities()
示例:
<?php
$filename = "test.html";
echo "<pre><code>";
echo htmlentities(file_get_contents($filename));
echo "</code></pre>";
?>
关于php - 在php中显示html文件的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14384065/