开发者

Is there any program that helps you check PHP codes?

Just a curious question but is there any programs that can help/aid you when you write PHP codes? Say there is an error in your code and using this program it would help yo开发者_高级运维u locate it, etc.

I might be thinking too much...


As a personal preference, I use Eclipse PDT. Its an integrated development environment for PHP, and comes equipped with syntax as well as error syntax highlighting and a helpful debugger.

Also, with WAMPserver installed, I can easily execute my code after editing and run it on my browser, definitely comes in handy.


Xdebug might be useful.


Yes, pretty much any modern IDE can do this for you. Try these:

  • Netbeans
  • Eclipse
  • Aptana
  • Komodo Edit

It will put red squiggly lines (like spellcheck) under errors as you type.


Most IDE's (Eclipse PDT has mention, and its my personal preference as well) have some sort of display que for what it thinks is an error. On top of that ther are fulll debuggers like XDebug which you can install that let you set through code a line at a time and set break points and what not.


I mainly use vim for editing and I make sure the php executable is in my path so I do this for a quick syntax-check on whatever file I have open.

:! php -l %

If I'm developing on a Windows machine, I install XAMPP just so I can use the php binary that comes with it.


set error_reporting(E_ALL); (while writing the code, when you have already uploaded your project for public usage, set error_reporting(0);)

It is much easier to find your own mistakes with error_reporting(E_ALL); You can try two following examples

//error_reporting(E_ALL);
$result = ($value > 0)?'Foo':'Bar';

vs

error_reporting(E_ALL);
$result = ($value > 0)?'Foo':'Bar';


You can run php in lint mode. It will parse the file and report errors, but won't execute any code:

php -l file.php

Otherwise, this post has a number of links to static code analysis tools for php.


i use textmate (on mac) for all my code it has syntax checker for php amongst other things

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜