Jump to content

Need advice on how to debug in the middle of code


Recommended Posts

I need some advice on how to debug in the middle of other code

 

I want to change a file. This file gives no direct output and contain a load of functions

 

What I want to do is make changes to this file and trace values - how do I do this?

 

- Can I give a popup with a message?

- Could I write values to a file? (Can I write to some sort of standard log file? Maybe the error log file?)

- Or is it possible to still give output to a web page, even though the code is not part of the code that outputs to the browser?

 

What's the standard practice of debugging as mentioned above?

 

Any help would be really appreciated

 

Thanks!

 

 

OM

 

hmmm i'm not sure how to best explain otherwise

 

if u do an echo anywhere, will that ALWAYS put to the browser?

i assumed the not

 

lets say you have a library of functions that process data, one of the called function x() and other function that display data to the web browser call this function x() before displaying the data

 

how could i debug function x()?

how could i set a value somewhere within function x() and test if it was set

surely you can't just do an echo?

 

specifically though: i'm having problems with a wordpress plugin, tweetmeme

see the attached for the code

i don't want the code to run if the content has '<!--NoTweet-->' in

so i have this: if((strpos($content,'<!--NoTweet-->'))

 

i tried putting this in the twitter_update($content) function - since this iswhere the return $content calls seem to have been made - but whatever i do, it has no effect

 

hence my original question of how to debug - one thing i wanted to do was to find out if the code i was putting in was actually being executed!

 

(i thought i would ask the question in a general format - it's a problem I've faced in the past with other code)

 

any replies would be great

 

thanks!

 

[attachment deleted by admin]

Have you tried to echo the variable values to see what happens?

 

If that doesn't work, then yes you can easily output the values to an external txt document. There is plenty of help on the web on how to do this.

 

But I would first actually try to echo the value, as I'm sure it will work.

 

Denno

Unless the overall code on the page is doing something that prevents output from being send to the browser, you can echo anything you want and it will be sent to the browser.

 

In those cases where the output is being sent inside of a HTML tag or inside of some css/javascript, you may need to do a 'view source' in your browser to see it, since it won't be displayed by the browser, but it will be present in the html source of the page.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.