Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I debug a php script?

Posted on 2010-09-10
6
Medium Priority
?
417 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
ID: 33648313
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
ID: 33648489
Check the apache error.log file.  It usually has some very helpful error or warning entries regarding a misbehaving php script.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 33652880
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:LL0rd
ID: 33654853
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 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 33656543
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
ID: 33658057
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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.
Suggested Courses

971 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