PHP – Parse error: syntax error, unexpected end of file

FastCGI sent in stderr: “PHP message: PHP Parse error: syntax error, unexpected end of file in /your_path/yourscript.php on line 308” while reading response header

This is the error when I check the php log file. Because I met the blank page with 500 internal error, which is loaded OK on the other server.

The real reason is I use (<? ?> ) and (<?php ?>) in mix. So I faced with this parse error when running the script on different systems:

Parse error: syntax error, unexpected $end in X on line Y

where X is the file path and Y the line number, usually the last line of the file. But the shotform may not there.

To avoid this error, refrain yourself from using the short form and stick to ( <?php ?>), despite the extra 3 characters. This will make your code universally accessible and it is essential if your developing for beyond your own personal use. If you insist in using the short form (<? ?> ), and you get this error, you can enable the short form option in the php.ini file.

short_open_tag=On

Keep in mind though, that the short form is supposed to be deprecated in PHP 6. If this goes through you will have to go back and change all your source files.

 

In the furture, I wil keep using long form of it only.