How to use
- Paste the PHP code you want to check into the input box. It starts with a sample that contains a few slips.
- Pick the target PHP version. Removed and deprecated functions are judged against it, and your choice is remembered in this browser.
- Read the errors, warnings and notes in the result table, each with a line:column position and the line itself.
- Fix the code and the table updates immediately. An unclosed string or comment hides everything below it, so start from the first row.
This tool is not a full PHP parser. It reads tags, strings, comments and brackets with its own tokenizer and applies a handful of rules. It does not replace php -l, and passing this check does not mean the code runs. It does not check whether variables or functions are defined, or whether types match.
What it checks
| Group | Check | Level |
|---|---|---|
| Tags | no whitespace after <?php, short tag <?, no PHP tag at all, <?xml declaration |
error, warning, note |
| Output | whitespace or BOM before <?php, blank lines left after ?> |
warning |
| Termination | unclosed single quote, double quote, backtick, heredoc, nowdoc or /* */ comment |
error |
| Brackets | unmatched ( ), [ ], { }, including attributes #[ ] |
error |
| Semicolons | places where a ; looks missing (end of line, end of file) |
warning |
| Compare and assign | assignment inside a condition such as if ($a = 5), a bare $a == 1; statement |
warning, note |
| Control flow | else if (an error with the colon syntax), an empty body as in if (...); |
note, error, warning |
| Paste problems | smart quotes, invisible spaces such as U+00A0, a $ with no name |
error, warning |
| Deprecated | mysql_*, ereg, split, create_function, each, money_format, strftime, utf8_encode and more |
error, warning, note |
Sample result
Checking the sample in the input box against PHP 8.3 gives 2 errors, 2 warnings and 1 note.
- Line 2, column 14: no semicolon after
$name = 'Kim'(warning) - Line 5, column 12:
=assigns inside theif ($count = 5)condition (warning) - Line 7, column 3:
else ifnests differently fromelseif(note) - Line 11, column 9:
mysql_connectwas removed in PHP 7.0; usemysqli_*or PDO (error) - Line 13, column 22: the opening
{offunction greet($who) {is never closed (error)
Deprecated and removed functions depend on the version
| Function | Deprecated | Removed | Use instead |
|---|---|---|---|
mysql_* |
5.5 | 7.0 | mysqli_*, PDO |
create_function, each |
7.2 | 8.0 | closures, foreach |
money_format |
7.4 | 8.0 | NumberFormatter |
strftime, gmstrftime |
8.1 | not yet | date(), IntlDateFormatter |
utf8_encode, utf8_decode |
8.2 | not yet | mb_convert_encoding() |
For example, money_format is a warning when the target is 7.4 and an error from 8.0, while strftime reports nothing up to 8.0 and becomes a warning from 8.1. Methods such as $o->each() and functions you define yourself are skipped.
Where false alarms can happen
- Missing semicolon candidates only look at the shape “a line ends with a value and a new statement starts next”. Lines that start with an operator (
.,->,?,and) and the line afterif (...)are skipped, but unusual formatting can still flag valid code. - = versus == candidates list idioms such as
if ($row = fetch())only as a note. Only an assignment of a literal, likeif ($a = 5), becomes a warning. - In template files,
?>counts as a statement end, so a missing final semicolon is not reported. - When a string is not closed, everything below it is unreadable and later problems stay hidden.
Frequently asked questions
How is this different from php -l?
php -l uses the real PHP parser, so it is exact. This tool is for places without PHP installed, to catch quotes, brackets and common slips quickly. Even after it passes, run php -l as well.
Why do I get “headers already sent”?
Whitespace or a BOM before <?php, or blank lines after ?>, is sent as output, so the response starts before header() or session_start() runs. This tool warns about both. In pure PHP files, leaving out the closing ?> avoids the trailing whitespace problem.
Where should I look for “unexpected end of file”?
Usually a { or ( was never closed, or a string never ended. The “has no matching closing bracket” rows point to where the bracket was opened, so start at that line.
A missing semicolon candidate shows up on valid code.
Candidates are estimated from rules and can be wrong. Look at the end of that line and the start of the next to see whether the statement really ended. When unsure, trust the php -l result.
Related tools: SQL Syntax Checker, HTML Validator, JavaScript Beautifier & Minifier, XML Validator, Regex Tester, Text Diff.
Your code is processed in your browser and never sent to a server.