readfile indents the first line when displaying on my page
The problem I am having is that when I use readfile in php on my page, the first line of the text is indented. Is there a way to fix this without going way out of my way or is this something that just has to be dealt with?
Below is both a snip of what is showing up and the code that is outputting this to my page. I have searched and can find nothing that would explain why this is happening.
Screenshot:
]
Code:
<!DOCTYPE html>
<html>
<pre>
<?php
$file = 'guestbook.doc';
if (file_exists($file)){
readfile($file);
} else {
echo "File cannot be read.";
}
?>
</pre>
<p>
<form action="GuestBook.html" />
<input type="submit" value="Return to Name Entry" />
</form>
</p>
</html>
Solution 1:
Whitespace inside <pre>
is not ignored. Put <?php
right after it:
<pre><?php
Same with closing ?>