I got an error:
Parse error: syntax error, unexpected end of file in the line
With this code:
also, look for a comment // that breaks the closing curly brace
if (1==1) { //echo "it is true"; }
the closing curly brace will not properly close the conditional section and php won't properly process the remainder of code.
In my case the culprit was the lone opening <?php
tag in the last line of the file. Apparently it works on some configurations with no problems but causes problems on others.
I had ran into this trouble when I left a php foreach: tag unclosed.
<?php foreach($many as $one): ?>
Closing it using the following solved the syntax error: unexpected end of file
<?php endforeach; ?>
Hope it helps someone
For me, the most frequent cause is an omitted } character, so that a function or if statement block is not terminated. I fix this by inserting a } character after my recent edits and moving it around from there. I use an editor that can locate opening brackets corresponding to a closing bracket, so that feature helps, too (it locates the function that was not terminated correctly).
We can hope that someday language interpreters and compilers will do some work to generate better error messages, since it is so easy to omit a closing bracket.
If this helps anyone, please vote the answer up.