2

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?

Junba Tester
  • 801
  • 2
  • 9
  • 15

6 Answers6

2

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
KingCrunch
  • 128,817
  • 21
  • 151
  • 173
1

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...

wojand
  • 142
  • 5
0

Install phpEclipse for syntax-checking:

http://www.phpeclipse.com/

Dolphin
  • 333
  • 1
  • 3
  • 9
0

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

Raffael
  • 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
0

Zend Studio (custom Eclipse) also has a syntax checker, FWIW.

TomL
  • 759
  • 8
  • 20
0

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.

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341