tracing a PHP script

This is a discussion on tracing a PHP script within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, all - -- I an building my first extensive PHP application. As I am doing so, I have backed myself into ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-06-2006
Swincher
 
Posts: n/a
Default tracing a PHP script

Hi, all - --

I an building my first extensive PHP application. As I am doing so, I
have backed myself into a corner where some messed-up logic is
stumping me big-time.

Is there a tool or technique with which I can step through the script
or trace through it so I can see the point at which my logic is
dropping down the hopper?

Many TIA

Ken
Reply With Quote
  #2 (permalink)  
Old 07-07-2006
-Lost
 
Posts: n/a
Default Re: tracing a PHP script

"Swincher" <kixjaguar@comcast.net> wrote in message
news:mqsqa2pvtqu3qhgupv55e26nbp4eo15ce8@4ax.com...

> Is there a tool or technique with which I can step through the script
> or trace through it so I can see the point at which my logic is
> dropping down the hopper?


exit(); // what does not happen?

if(condition) { ... } else { die($variable); } // is $variable right?

if(condition) { die(condition); } // stop, is condition OK?

function($do_stuff) or die($do_stuff . ' went down the hopper.');

If you are getting specific errors you could log them into a database, flat file or what I
like to do sometimes, write it in your markup (hidden from view, unless you use your
browsing client's view source).

Here is an article that might prove more useful.

http://www-128.ibm.com/developerworks/library/os-debug/

In general... are you receiving any errors? What is your code *not* doing? Can you show
us some source so we can have a go at it?

-Lost


Reply With Quote
  #3 (permalink)  
Old 07-07-2006
-Lost
 
Posts: n/a
Default Re: tracing a PHP script

Actual debug solutions...

Thanks to Alvaro in alt.php
http://groups.google.com/group/alt.p...2076d39306fd87

Xdebug
Then a program to use with it, WinCacheGrind
DBG at http://dd.cron.ru/dbg/ has a free version that might work.

Hope these help.

-Lost


Reply With Quote
  #4 (permalink)  
Old 07-07-2006
Centurion
 
Posts: n/a
Default Re: tracing a PHP script

Swincher wrote:
> Hi, all - --
>
> I an building my first extensive PHP application. As I am doing so, I
> have backed myself into a corner where some messed-up logic is
> stumping me big-time.
>
> Is there a tool or technique with which I can step through the script
> or trace through it so I can see the point at which my logic is
> dropping down the hopper?
>
> Many TIA
>
> Ken


You may want to investigate PHP unit testing. Googling the last three
words of my previous sentence reveals volumes of useful links :)

Cheers,

James
Reply With Quote
  #5 (permalink)  
Old 07-07-2006
Swincher
 
Posts: n/a
Default Re: tracing a PHP script

On Thu, 6 Jul 2006 20:21:36 -0400, "-Lost"
<spam_ninjaREMOVEME@REMOVEMEcomcast.net> wrote:

>In general... are you receiving any errors? What is your code *not* doing? Can you show
>us some source so we can have a go at it?


Thanks for the links and suggestions. No, I am not receiving errors as
these are logical flaws, not syntax errors. IOW, the program wasn't
doing what I wanted it to do. As it was getting more complex, I wasn't
able to find the flaws.

Yes, those references are past tense: I was able to figure this one
out, but I still will follow your links. It will make the next flaw
easier to diagnose.

Many thanks - - -

Ken
Reply With Quote
  #6 (permalink)  
Old 07-07-2006
Swincher
 
Posts: n/a
Default Re: tracing a PHP script

On Fri, 07 Jul 2006 15:28:14 +1000, Centurion <spam_this@nowhere.tld>
wrote:

>You may want to investigate PHP unit testing. Googling the last three
>words of my previous sentence reveals volumes of useful links :)



I'll do that. Thank you.

Ken
Reply With Quote
  #7 (permalink)  
Old 07-08-2006
kees hessels
 
Posts: n/a
Default Re: tracing a PHP script

Ive been using phped from nusphere which works good for me, it does have a
small price tag, but i realy like the editor and debugger..

"Swincher" <kixjaguar@comcast.net> wrote in message
news:mqsqa2pvtqu3qhgupv55e26nbp4eo15ce8@4ax.com...
> Hi, all - --
>
> I an building my first extensive PHP application. As I am doing so, I
> have backed myself into a corner where some messed-up logic is
> stumping me big-time.
>
> Is there a tool or technique with which I can step through the script
> or trace through it so I can see the point at which my logic is
> dropping down the hopper?
>
> Many TIA
>
> Ken



Reply With Quote
  #8 (permalink)  
Old 07-08-2006
IchBin
 
Posts: n/a
Default Re: tracing a PHP script

Swincher wrote:
> Hi, all - --
>
> I an building my first extensive PHP application. As I am doing so, I
> have backed myself into a corner where some messed-up logic is
> stumping me big-time.
>
> Is there a tool or technique with which I can step through the script
> or trace through it so I can see the point at which my logic is
> dropping down the hopper?
>
> Many TIA
>
> Ken


You could try PHPEdit

http://www.waterproof.fr/?PHPSESSID=...9605dda81c04ab


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Reply With Quote
  #9 (permalink)  
Old 07-08-2006
Gleep
 
Posts: n/a
Default Re: tracing a PHP script

It is very difficult correcting logic flow on a complicated app especially if you are using classes
with many functions it's hard to determine where variables are breaking down.

That is why I like to code in a step by step process, at the top of my pages and use a series of
includes. When doing something complex I stop the code flow with
echo "$vaiable1 $variable2";
exit;
and see am i getting the correct results here...
then I comment it out //
and do the same to the next section and so on. Only then when I know the logic is correct I will
then pull out code turn it into functions or parse it out to includes.

If using classes and functions. You will have to carefully test each function. extract/copy it out
and paste to test.php and rigorously test the function, try to break it, pass zeros, or null or '
and see what the results are.

if expecting arrays use print_r($arrayName); it will print out the array values.

It's a major pass in balls to track this shit down, must break it down to smallest components.

I recently downloaded an authorize.net php class from merchantplus.com by the way it's free and a
good study example. Anyway they class is way over the top and added tons of extra shit we didn't
need and in addition the validation logic was not working correctly. I spent an entire day trying to
figure out why - then said fart on it and wrote my own authorize.net script.

Anyway guess i'm going off on a tangent. Another trick I use is to insert javascript popups inside
php code and place it various spots to see are the vaiable being passed correct.
echo "<script language='javascript'> alert('$someVar');</script> ";





On Thu, 06 Jul 2006 15:35:49 -0500, Swincher <kixjaguar@comcast.net> wrote:

>Hi, all - --
>
>I an building my first extensive PHP application. As I am doing so, I
>have backed myself into a corner where some messed-up logic is
>stumping me big-time.
>
>Is there a tool or technique with which I can step through the script
>or trace through it so I can see the point at which my logic is
>dropping down the hopper?
>
>Many TIA
>
>Ken


Reply With Quote
  #10 (permalink)  
Old 07-08-2006
Rik
 
Posts: n/a
Default Re: tracing a PHP script

Swincher wrote:
> Hi, all - --
>
> I an building my first extensive PHP application. As I am doing so, I
> have backed myself into a corner where some messed-up logic is
> stumping me big-time.
>
> Is there a tool or technique with which I can step through the script
> or trace through it so I can see the point at which my logic is
> dropping down the hopper?


I normally work with a lot of userdefined functions & classes. In the
development fase, I often do this:

$flow = array();

And in functions:
global $flow;
$flow[] = debug_backtrace();

Which will give you method / function, class, line, filename & arguments
used.
print_r($flow); will give me the total flow until that point.

You could print_r(array_slice($flow,-15)) to get only the last 15 statements
to avoid huge amounts of OK code to read through.

Grtz,
--
Rik Wasmus


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0