A PHP Parse Error occurs when the PHP engine encounters a syntax mistake in a script, preventing the code from executing. This article helps you identify the specific file and line number causing the error on your website so you can correct the code.
Before you begin
You will need:
Access to your website's files via an FTP client or a web-based File Manager.
Access to your website's error logs or a way to view the error output on the page.
Check the error message for file and line details
When a Parse Error occurs, the server typically generates a message containing the specific location of the mistake.
Load the page on your website that is triggering the error.
Locate the error message on the screen.
Identify the file path and the line number provided in the error.
Note: A typical Parse Error message will look like this: Parse error: syntax error, unexpected '...'; in /home/user/public_html/wp-content/plugins/plugin-name/file.php on line 123.
Identify the cause of the error
Once you have the file path and line number, examine the code at that specific location. Common causes include:
Missing Semicolons: A missing
;at the end of a statement.Unclosed Brackets or Parentheses: A missing
}or)that causes the script to fail.Typos in Keywords: Misspelling a PHP function or keyword (e.g.,
functoninstead offunction).Incorrect Concatenation: Using the wrong symbol to join strings.
Resolve the error
Open the identified file using a text editor or your hosting provider's File Manager.
Navigate to the line number indicated in the error message.
Correct the syntax error.
Save the file and refresh your browser.
If the error message is not visible on the page
If your website shows a blank page or a generic "500 Internal Server Error" instead of a detailed Parse Error, you must check the server logs to see the specific error details.
Log in to your hosting control panel.
Navigate to the Errors or Logs section (the location varies depending on your specific control panel).
Look for the most recent entries related to your website's domain.
Locate the "Parse error" entry to find the file path and line number.
Follow the steps in the Identify the cause of the error section above.
Limitations
A Parse Error is a "fatal" syntax error. Because the code cannot be parsed by the server, the page will not load at all until the specific syntax mistake is corrected. This is different from a "Warning" or "Notice," which allow the page to load even if the code is imperfect.
