使用file_get_contents读取PHP代码

时间:2010-08-26 14:45:21

标签: php

file_get_contents函数似乎无法从.php文件中读取PHP代码。它似乎忽略了<?php标记后的所有内容。

为什么会这样?

1 个答案:

答案 0 :(得分:13)

我想这不是file_get_contents,而是打印内容的方式。将htmlspecialchars放入HTML文档时,使用{{3}}可以正确编码内容:

echo '<pre>', htmlspecialchars(file_get_contents('file')), '</pre>';