tags:

views:

83

answers:

2

So I've got all of this really neato PHP code and I've started doing some reuse with functions out of necessity. I'm debugging, trying to figure out why I can't delete comments on my website while I'm deleting folder (because who wants orphaned comments?)

So I have a call to deletefolder( $parent) inside a file called deletefolder.php. This a function that will recursively traverse my tree structure.

I've include another file inside deletefolder.php. The file is call helpers.php, and it contains the deletefolder function.

The deletefolder function calls deletecomments (kills all the comments per file) and delete file (which kills the file itself).

Now, all of it is just slathered with echo statements to help me figure out what's going on. When I call this combination of functions from other locations I don't seem to have a problem getting messages. But when I call them from the deletefolder.php page I don't get any. Does anybody know why this would be the case?

A: 

Well, I seriously doubt you've found a bug in the echo command, so the problem is with your program logic somewhere. Without seeing your code, it's impossible to say really. Perhaps there's some variable being set or unset unexpectedly, or you're not actually include()ing the files properly.

nickf
Thank you for your comment, though I wasn't suggesting that echo itself had a problem as it's working fine elsewhere. This same include file is being used in a number of other files (I've got a bunch of functions in there) and they all seem to be working properly. Just not this combination.
Michael Beck
+2  A: 

A few things you might want to verify.

  • Check the source of the output. You might be echoing straight in a middle of a HTML comment or a tag which is hiding the output.

  • Are you using output buffering (ob_start()) ? You might be clearing the buffer at some point in your code and forgot all about it.

  • Different files with the same name but not in the same directory. Do a die() in your function to make sure it actually reaches your code. You might be editing/including a copy of your file (happened to me quite a few times).

Andrew Moore
Hey, thanks for getting back so quickly. That's interesting about the html tag. I hadn't considered that. I will investigate it.No, I'm not using ob_start anywhere. I will also try using die as well. Thank you.
Michael Beck