0

I was debugging by adding a print_r() to my code to check array values along the way. The problem is I forgot where (which module and which file) I had added the print_r() statement since it has been some time I had worked on it. Now some of my pages are outputting an unwanted array print out. Is there a way to find out which module and which file specifically generated the array print out?

1

If you are running on Gnu/Linux or Unix, you should be able to position yourself above the directory holding your code and use the following shell command:

grep -r print_r .

This will recursively search through the current directory and all the directories below it for the string "print_r" and print out all lines containing that string, prefixed with its file name.

For future debugging, I suggest you install the Devel module for debugging. At least one of its debug printout functions (dpm()) will print where the debug statement is placed by name of file and line number if the object is complex enough to produce a Krumo accordion display of the object/array.

For simpler objects, use the second argument to dpm() to remind yourself where you placed it. E.g.:

dpm($uid, 'mymodule, line 42, $uid');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.