DEV Community

Lalit Kumar
Lalit Kumar

Posted on

PHP parse error: syntax error, unexpected end of file

Unexpected End of File error occurs when a file does not have a proper closing tag. Sometimes this error can present itself as the White screen of death, or a 500 error. If so then you can able to determine the error is caused by an “unexpected end of file” by looking at your error logs in your WP Engine User Portal.


title: "PHP parse error: syntax error, unexpected end of file"
tags: php

canonical_url: https://kodlogs.com/blog/701/php-parse-error-syntax-error-unexpected-end-of-file

Solution:

This error can be solved in two ways;

  • Restore the website
  • Correct the file ##Restore the website: Once you have confirmed the issue is due to an unexpected end of file error, then the simplest way to resolve the issue is to restore the website to the last known good state, if it is possible. This is most likely the point just before any recent code changes.

Correct the file:

If restoring the website is not a valuable option, then you can also fix it by downloading it over SFTP or opening it in SSH Gateway. Once you fixed the broken file by adding a proper closing tag, be sure you have saved and uploaded the file. You may also need to purge the cache.

After fixing the file, your website should normally again.

Top comments (0)