PHP Parse Errors-syntax mistakes and fixes
Fix "Parse error: syntax error" in PHP. Missing semicolons, braces, quotes, and debugging parse errors.
A parse error (syntax error) means PHP couldn't understand the code because of a grammatical mistake - missing semicolon, brace, quote, or wrong syntax. PHP stops executing and displays the error.
Common parse errors
- Missing semicolon: Most common - end statements with ;
- Missing closing brace: { } must be paired
- Missing closing quote: "string" must have matching quotes
- Wrong variable syntax: Use $variable, not variable
- HTML in PHP: PHP closing tag ?> then HTML then opening tag <?php causes issues
How to find the problem
Error message shows: "Parse error in /path/to/file.php on line 25"
BUT: The actual error might be on line 24 or earlier! PHP doesn't always pinpoint the exact line.
Check error log:
# WordPress
tail -20 /wp-content/debug.log
# VPS
tail -20 /var/log/php-errors.log
Common fixes
Check surrounding lines (2-3 lines before error):
- Line 23: Missing semicolon at end?
- Line 22: Unclosed quote?
- Line 20: Unclosed brace?
Use IDE/editor with PHP syntax checking:
- VS Code with PHP Intelephense extension highlights errors
- PHPStorm has built-in syntax checking
Isolate the problem:
- Comment out half the file (add /* before and */ after)
- Does site load? If yes, error is in commented part
- Comment out half of that section, repeat
PHP reports where it noticed the error, not where the error actually is. Always check a few lines before the reported line number.
Related: Fatal PHP errors | WordPress troubleshooting
Still troubleshooting?
Use UnderHost tools for quick checks, or open a support ticket when the issue needs account or server access.





















