Junba Tester
Junba Tester

Reputation: 851

php compiler or syntax checker

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?

Upvotes: 2

Views: 3694

Answers (6)

Ira Baxter
Ira Baxter

Reputation: 95354

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.

Upvotes: 0

TomL
TomL

Reputation: 759

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

Upvotes: 0

Raffael
Raffael

Reputation: 20045

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

Upvotes: 0

wojand
wojand

Reputation: 142

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

Upvotes: 1

KingCrunch
KingCrunch

Reputation: 131891

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

Upvotes: 2

Dolphin
Dolphin

Reputation: 343

Install phpEclipse for syntax-checking:

http://www.phpeclipse.com/

Upvotes: 0

Related Questions