943,832 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 8134
  • PHP RSS
Dec 12th, 2007
0

PHP Syntax checking

Expand Post »
Hello all,

I've been working for awhile building a web with PHP. So far, so good. But I'm finding refactoring to be frustrating, because I haven't found a tool that will give a full syntax check across my code. Yes, there is the "php -l" command to do the lint-style check, but that's a very basic check. I'm thinking of a case where I define

PHP Syntax (Toggle Plain Text)
  1. function foo() {
  2. ...
  3. }

in one file and then call foo() from another file. In the course of refactoring, I change "foo()" to "betterName()". In a compiled language, any reference to foo() that I missed changing would cause a compilation error. Since PHP is interpreted, I only see an error when I load a page that hits the specific line of code with the error. Thus, it's easy to miss an error.

So the question: does anyone know of a tool that will do a real syntax check, even to the level of making sure called functions are actually defined? I've been looking for a while, but I haven't been able to find anything.

Thanks,

Dave.
Similar Threads
Reputation Points: 22
Solved Threads: 0
Newbie Poster
dmc72 is offline Offline
8 posts
since Dec 2007
Dec 12th, 2007
0

Re: PHP Syntax checking

php designer does a good job with debugging. Like php, its free to download. It has a code coloring scheme similar to dreamweavers that will help you spot syntax errors and the debug will find errors and tell you what line the error is found on.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Dec 12th, 2007
0

Re: PHP Syntax checking

Click to Expand / Collapse  Quote originally posted by buddylee17 ...
php designer does a good job with debugging. Like php, its free to download. It has a code coloring scheme similar to dreamweavers that will help you spot syntax errors and the debug will find errors and tell you what line the error is found on.
Thanks for the quick response. I just took a look at phpDesigner's web site. It has a free trial version, good for 14 days, then it's 39 euro for one license.

Unfortunately, it doesn't run on Mac, so I won't be able to try it out until I get home. (I do most of my work on a Mac laptop.) Since I can't run it, I just took a look at the web site. I see that it does syntax checking, but it looks like it's just the basic syntax checking you can do from the command line with "php -l". I'm using the PHP plugin for Eclipse, which can also do that. I'm looking for a bit more.

a.php:
PHP Syntax (Toggle Plain Text)
  1. function foo() {
  2. echo '<p>This is foo()';
  3. }

b.php:
PHP Syntax (Toggle Plain Text)
  1. require_once('a.php');
  2.  
  3. foo();

I point my browser at b.php, and I'll get some simple output. Now, suppose I edit a.php and change "foo()" to "bar()", but don't change b.php. When I point my browser to b.php, I'll get an undefined function error. I'm looking for a tool that will find that error without me having to view b.php in a browser (because presumably I have lots of pages, and the call might be within some if statements, and I don't want to have to execute every line of code I have to catch the error). Eclipse's plugin doesn't find it, the php command line tool doesn't find it, and looking at http://www.mpsoftware.dk/phpdesigner_features.php, it doesn't look like it will either (one listed feature says "Syntax check PHP using the PHP Interpreter").

I'm thinking of the work I've done in Java, C++, and other compiled languages. If I make a change like this, then the compiler will look at all my code and complain that it can't find foo(). It does the checking for me and gives a list of problems.

Sorry if this is redundant, just trying to be clear.

Thanks again,

Dave.
Reputation Points: 22
Solved Threads: 0
Newbie Poster
dmc72 is offline Offline
8 posts
since Dec 2007
Dec 13th, 2007
0

Re: PHP Syntax checking

Probably the best debugging in PHP will be in Zend Studio (I use professional) which is cross-platform. There should be a free trial on their site. It does a pretty good job of picking apart your code like a crazy english teacher with a red pen.

Despite the high price tag, I do highly recommend it.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sumwatt is offline Offline
1 posts
since Dec 2007
Dec 14th, 2007
0

Re: PHP Syntax checking

please use mozilla firefox and download firebug as add on and then install it.anytime there is error in the browser it track it for u
Last edited by ebencosoft; Dec 14th, 2007 at 5:24 am.
Reputation Points: 9
Solved Threads: 0
Newbie Poster
ebencosoft is offline Offline
3 posts
since Dec 2007
Dec 18th, 2007
0

Re: PHP Syntax checking

Click to Expand / Collapse  Quote originally posted by sumwatt ...
Probably the best debugging in PHP will be in Zend Studio (I use professional) which is cross-platform. There should be a free trial on their site. It does a pretty good job of picking apart your code like a crazy english teacher with a red pen.

Despite the high price tag, I do highly recommend it.
Thanks for the suggestion, sumwatt. I checked out Zend Studio, but unfortunately, it doesn't offer what I'm looking for either. Their code analyzer is pretty cool (and found some interesting screwups), but it doesn't check that a function you've called actually exists somewhere. In a project setting, it seems like it ought to be able to do that. Oh well.
Reputation Points: 22
Solved Threads: 0
Newbie Poster
dmc72 is offline Offline
8 posts
since Dec 2007
Dec 18th, 2007
0

Re: PHP Syntax checking

Click to Expand / Collapse  Quote originally posted by ebencosoft ...
please use mozilla firefox and download firebug as add on and then install it.anytime there is error in the browser it track it for u
I've been using Firebug for a while and it's a fantastic tool for figuring out problems with JavaScript, CSS, and other client side problems, but it doesn't address what I'm looking for in PHP.
Reputation Points: 22
Solved Threads: 0
Newbie Poster
dmc72 is offline Offline
8 posts
since Dec 2007
Dec 19th, 2007
-1

Re: PHP Syntax checking

please download PHP designer from www.phazeddl.com and use it. the software will indeed help in debugging PHP and i bet u will like bros
Reputation Points: 9
Solved Threads: 0
Newbie Poster
ebencosoft is offline Offline
3 posts
since Dec 2007
Dec 19th, 2007
0

Re: PHP Syntax checking

phpDesigner's official site appears to be http://www.mpsoftware.dk/, so I would download it from there. Looking over their web site, I don't see anything that suggests they have the feature I'm looking for. However, since it's not the first time this tool's been suggested, I decided to just write to them and ask. I'll post the answer when I get it.

Dave.
Reputation Points: 22
Solved Threads: 0
Newbie Poster
dmc72 is offline Offline
8 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: new to PHP
Next Thread in PHP Forum Timeline: recommend a php book





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC