Solved

How can I debug a php script?

Posted on 2010-09-10
6
410 Views
Last Modified: 2012-05-10
Hi,

I have a problem with a php script, I bought. Sometimes it just hangs on some operation. The script has about 3k lines, so I can't analyse the script and add debug output messages to it. Is it somehow possible to debug it? I just want to know, what (on what line[s]) the server is currently working on.
0
Comment
Question by:LL0rd
6 Comments
 

Expert Comment

by:ilevex
Comment Utility
Try to add some debug lines only to some more important lines, then try to add to less important ones. Also look at the script's output, and try to figure out where it hangs. Give it easy vars, like 1, and calculate it in your brain. Hope I helped. ;)
0
 
LVL 3

Expert Comment

by:kf4zmt
Comment Utility
Check the apache error.log file.  It usually has some very helpful error or warning entries regarding a misbehaving php script.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Make sure you have error reporting turned on.  Set error_reporting(E_ALL).  But the larger question is, if you "bought" the script the seller has some obligation related to merchantability.  I would go back to the source and ask for help.  I think they would be VERY GLAD to offer assistance and would be grateful for the opportunity to remove a bug from future versions.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Author Comment

by:LL0rd
Comment Utility
First of all an external application is accessing  the script twice a day and makes the script on my server hangs. I can't Access and error logfiles does not have any information about the error, even with E_ALL. Yesterday I installed mod_dumpio on the server to get the input data, that causes problem. To my surprise I couldn't cause the hang with exact the same data, that coused it the last time. Now I also tried to add some code lines with debug output, but it didn't helped me. The problem appeared twice since than, but I got the last output from different lines. That's why I think, the problem is caused by a method or function. But I don't want to add debug output lines to every function - it's quite a lot of work.

@Ray Paseur
I have allready talked to the seller. Without any results. I'm from Germany, here people try to defend their work. So the seller said to me: "Hey, I sold this script a lot of times and you are the only customer with that problem. It must be the fault of your server. And you are the only person, who have root rights on the machine, so you can see, what is going on. And maybe the Server is not powerfull enough". But well - I also can't see, what is going on. And the machine is a Sun X4150 server with 16GB RAM and 8x 3GHz Xeon with 5 SAS HDs on a HW Raid controller with 256MB Cache @Raid5. It's a high end machine.

Well for me, it's not important that the seller fixes the bug, I just want to use the script (now and not in a few days/weeks/month, on the next release).
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
When you say it "hangs" does that mean an endless loop or an endless wait?  If it is a loop, you might be able to set a very short time limit and catch an instruction line number when the server terminates the script.

Is the script OOP code?  If so, how many methods are present?  Even with 3,000 lines of code it would not seem that hard to a few error-logging statements, perhaps one per method.  Something like that may help you if the error is data-dependent.
0
 
LVL 25

Expert Comment

by:madunix
Comment Utility
I do php programming/debugging  with help of eclipse..
The free and popular Eclipse development environment gives programmers a feature-rich editor, version control manager, and debugger on a shared GUI. Eclipse was designed as a universal IDE that is easily extensible to accommodate a variety of programming languages. The PHPEclipse plugin converts Eclipse into a full-fledged IDE for PHP-based dynamic websites. Another plugin called Subclipse integrates version control with the Subversion version management system. In this article, we describe how to set up a PHP development environment with Subversion and Eclipse.

http://www.linux-magazine.com/w3/issue/87/PHP_Programming_With_Eclipse_IDE.pdf
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now