php获取文件内容并将其格式化打印出来


php fetch file content and print it out formatted

如何打印格式化的HTML文件?这是我当前的代码:

echo htmlspecialchars(file_get_contents($url)); 

但结果看起来很难看,所有的东西都粘在一起,没有空格,没有标签。有没有办法像原始文件一样打印文件?

预标记会起作用。

<pre>
<?php echo htmlspecialchars(file_get_contents($url)); ?>
</pre>