Solved

How can I debug a php script?

Posted on 2010-09-10
6
415 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
Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

630 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