Emanuil Rusev
Emanuil Rusev

Reputation: 35235

Reading PHP code using file_get_contents

The file_get_contents function doesn't seem to be able to read PHP code from .php files. It seems to ignore everything after a <?php tag.

Why might be that?

Upvotes: 1

Views: 1894

Answers (1)

Gumbo
Gumbo

Reputation: 655239

I guess it isn’t file_get_contents but the way you print the content. Use htmlspecialchars to have the content encoded properly when putting it out into an HTML document:

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

Upvotes: 13

Related Questions