Knowledgebase

Parse error: syntax error, unexpected Print

  • errors, php, backup, restore, woocommerce, diskspace, troubleshooting, uploads
  • 0

A file contains invalid PHP.

WHAT IT MEANS

PHP could not read the file at all. Nothing runs.

The error names the file and the line.

THE COMMON CAUSES

A recent edit introduced a mistake: a missing semicolon, an unclosed brace, an unmatched quote

Code pasted from a website that included smart quotes instead of straight ones An incomplete file upload Copying a snippet that included the opening PHP tag into a file that already had one

THE FIX

Open the named file and look at the line given, and the lines immediately before it.

The error frequently appears on the line after the actual mistake, since that is where PHP notices.

IF YOU JUST EDITED IT

Restore your backup copy. This is why copying the file before editing matters.

IF YOU PASTED A SNIPPET

Check for curly quotation marks. Text editors and websites substitute them, and PHP rejects them.

Retype the quotes.

CHECKING WITHOUT RUNNING

Over SSH, php -l against the file reports syntax errors without executing it.

Do this before reloading a site after editing.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot