OM2 Posted January 15, 2011 Share Posted January 15, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/224485-need-advice-on-how-to-debug-in-the-middle-of-code/ Share on other sites More sharing options...
revraz Posted January 15, 2011 Share Posted January 15, 2011 Not sure what you mean by the middle of other code. Are you talking about includes? You can put echo breaks where ever you want. Quote Link to comment https://forums.phpfreaks.com/topic/224485-need-advice-on-how-to-debug-in-the-middle-of-code/#findComment-1159622 Share on other sites More sharing options...
OM2 Posted January 15, 2011 Author Share Posted January 15, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/224485-need-advice-on-how-to-debug-in-the-middle-of-code/#findComment-1159633 Share on other sites More sharing options...
denno020 Posted January 15, 2011 Share Posted January 15, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/224485-need-advice-on-how-to-debug-in-the-middle-of-code/#findComment-1159637 Share on other sites More sharing options...
PFMaBiSmAd Posted January 15, 2011 Share Posted January 15, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/224485-need-advice-on-how-to-debug-in-the-middle-of-code/#findComment-1159641 Share on other sites More sharing options...
trq Posted January 15, 2011 Share Posted January 15, 2011 If you where using classes I would recommend unit testing with php unit. A simpler 'debug' system that I used allot at work is FirePHP which plugs into Firefox's Firebug extension. Quote Link to comment https://forums.phpfreaks.com/topic/224485-need-advice-on-how-to-debug-in-the-middle-of-code/#findComment-1159642 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.