1

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?

2
  • what the error you get ? some code Commented Aug 26, 2010 at 14:47
  • No error. It's just that the returned value seems to be empty. Commented Aug 26, 2010 at 14:50

1 Answer 1

13

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>';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.