Jump to content

How to debug a file that doesn't output


OM2

Recommended Posts

If I have a file that is full of functions that do 'things',  I assume if I wanted to debug or test that it would necessarily work if I try to echo from inside of a function?

 

In that case, what do I do if I want to test or debug?

The only thing I can think of is creating a file and writing to it

But is this the only way

Could I write to a log file - without going to the bother of opening and closing a file or something?

 

Thanks

 

 

OM

Link to comment
Share on other sites

Maybe, I'm doing something wrong

Are you saying that if I echo ANYWHERE, as long as that part of code is run, and echo will ALWAYS output to the screen?

Are there no circumstances where this won't be true?

 

I have a Flash file that uploads files and then runs a php script

In this php script, I have put echo statements next to code that I know 100% it runs - but I get no output

 

Am I doing something wrong?

 

Thanks

 

Link to comment
Share on other sites

Perhaps a header redirect before the echo gets a chance to run?

 

Is the file being called by the flash application rather than the browser? Similar to an AJAX call? If so, you'll have to find a way to get the flash application to give you the text returned by the script.

Link to comment
Share on other sites

Perhaps a header redirect before the echo gets a chance to run?

 

Is the file being called by the flash application rather than the browser? Similar to an AJAX call? If so, you'll have to find a way to get the flash application to give you the text returned by the script.

yes being called by flash file

forgetting flash for a second, if an echo is done, will it ALWAYS output to the browser?

thanks

Link to comment
Share on other sites

Assuming the browser is executing the script, it should output to the browser (though client-side configurations can affect this - plugins like adblock will hide pre-defined lists of images etc.)

 

There are functions that can prevent this however, like ob_start() and ob_end_clean(). If you haven't coded any output buffering into your script though, I really wouldn't be worried.

Link to comment
Share on other sites

thanks

that's really helpful

 

i was going through some code a freelancer coded for me and they used ob_start()

i looked up on php.net, but couldn't get my head round what it was supposed to do and why one might use it?

Link to comment
Share on other sites

Here's a read that tells you everything you need to know about how PHP handles outputs

 

http://phpadvent.org/2010/output-buffering-by-nicholas-sloan

 

I don't really like using output buffering. I don't ever see a need for it myself with the rare exception of a pesky function that outputs directly rather than returning a value. Just my personal opinion - some good programmers use it, other good programmers don't. Just about anything you can do with output buffering can be done without it.

Link to comment
Share on other sites

hey: that's a great article

i have a good understanding now

and can see the benefits of using

it's really annoying creating a damn string and continually concatinating to

 

i've book marked the site as well - its got a lot of useful articles

 

thanks!

 

Link to comment
Share on other sites

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.