开发者

Good resources to learn php debugging [closed]

开发者 https://www.devze.com 2023-01-04 00:09 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We开发者_开发知识库 expect answers to be supported by facts, references,or expertise, but this question will likely
As it currently stands, this question is not a good fit for our Q&A format. We开发者_开发知识库 expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

What are the best resources do you recommend for learning php debugging?

Is there any specific book, screencast, blog post or article that you really found useful?


Here's a list of what I could find in a quick google search. The second link is software, the rest are articles except from the last two which are videos. I personally liked the last one since it uses Np++ and Xdebug.

  • Debugging techniques for PHP programmers
  • DBG | PHP Debugger and Profiler.
  • PHP Debugging Basics
  • Debugging PHP with NuSphere PHP IDE debugger
  • Debugging PHP scripts with Xdebug and Notepad++

Anyway, most of the time all you need to do is keep your code readable and name your variables and functions correctly, don't be afraid of using long names for them like $arr_dates_meetings instead of $meetings. It will decrease your mistakes since you will locate problems easier. Also make sure that while developing you keep track of the values of your declared variables. Maybe use something like get_defined_vars() to return them all, or just the ones that interest you.

The video I mentioned is rather slow paced so you're probably better off just checking the article it's based on: Debugging PHP using Xdebug and Notepad++


old good article from IBM DeveloperWorks
http://www.ibm.com/developerworks/library/os-debug/

Though the main idea of debugging is quite simple: you have to understand what your program does. And when something goes wrong, you have to do just step-by-step checking, stopping at certain points, checking values of variables. This way you can determine a problem part.
And system error messages always to help too.
That's all.


I really find useful the following function:

function echo_r($x){
    echo '<pre>';
    print_r( $x );
    echo '</pre>';
}

While far from a debugger, it's really useful for inspecting variables. Using it I hardly ever need a real debugger, i just sprinkle the code where I need to inspect and hit reload.

There is also var_dump but I prefer the first approach.

function echo_r($x){
    echo '<pre>';
    var_dump( $x );
    echo '</pre>';
}
0

精彩评论

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