I'm looking for a php syntax checker, preferably as an eclipse plugin, preferably be able to sort of compile it(at least find undefined variables in addition to syntax checking. Does such thing exist?
6 Answers
Every better IDE (PhpStorm, Eclipse/PDT, Eclipse/PHPEclipse, Netbeans with PHP-Plugin, and so on) comes with automatic syntax check built-in. At least PhpStorm is able to find undefined variables. The last time I used PDT it didn't support it. PHPEclipse seems to be not maintained anymore, so I assume, that it cannot find undefined variables too, and netbeans ... don't know.
If you just want to check the syntax the quick&dirty way, you can use the php-interpreter itself
php -l filename.php

- 128,817
- 21
- 151
- 173
Of course, look on this: http://www.eclipse.org/pdt/
This IDE using php parser engine to syntax, and is for free :-). But, better do not use the plugin version from update site, but All-In-One Package. At least previous versions from update site did not work too well...

- 142
- 5
In PHP there is no such thing as an undefined variable. Variables are automatically initialized with null.

- 19,547
- 15
- 82
- 160
-
This is not true. Run this on the command line and see the undefined variable warning for yourself: `php -r "if ($a) { echo 'foo'; }"` – Oz Solomon Oct 15 '13 at 22:02
Our PHP Formatter parses PHP code to an AST, and then prettyprints the results. This can be used as a command-line script. If the source file isn't parsable, the tool exits with with an error (and doesn't prettyprint). So, if you ignore the prettyprint feature, this is precisely a command-line level syntax checker. Easy to launch from Eclipse.

- 93,541
- 22
- 172
- 341