Solved

How can I debug a php script?

Posted on 2010-09-10
6
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 110

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
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 
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 110

Accepted Solution

by:
Ray Paseur earned 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

751 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