0

Possible Duplicate:
How to find out where a function is defined?

in a client's website I have a php code:

return userHasActivePurchase($iId);

The website is full of icludes, requires. I have made a full text search on "userHasActivePurchase" to find out what php file does contain this function without success.

My question is : I have a function name and I would like to know what php files contains that function.

I tried with:

print_r(userHasActivePurchase);

without success.

Please help !

Community
  • 1
  • 1
yarek
  • 11,278
  • 30
  • 120
  • 219
  • For fun: try to pass in a parameter that should trigger an error/notice in the function :). – kapa May 09 '12 at 09:26
  • 2
    One day you need to explain why `print_r` should output information about an undefined constant, but if you enable error reporting you will improve your code fast. – hakre May 09 '12 at 09:27

3 Answers3

1

As per this stackoverflow thread:

$reflFunc = new ReflectionFunction('function_name');
echo $reflFunc->getFileName() . ':' . $reflFunc->getStartLine();
Community
  • 1
  • 1
Matt
  • 9,068
  • 12
  • 64
  • 84
  • 1
    Please either add a comment or flag as a duplicate instead of copy-pasting the other answer. – kapa May 09 '12 at 09:24
  • Sorry, thought it would be the quickest way to get the answer here. Should I now remove this answer? – Matt May 09 '12 at 09:25
  • Please remove the answer (if you don't mind that 10 rep point :)), the question will be closed soon as a duplicate. – kapa May 09 '12 at 09:28
0

You can search for text "function userHasActivePurchase" in the whole code base using grep command or by any editor's native search in directory function.

If you find this function defined at more than one place you can recognize it by putting a statement inside the function in all the files

echo __FILE__

piyush
  • 976
  • 4
  • 13
  • 28
-1

get a decent ide (phpstorm, eclipse pdt) which will allow you to follow code - or even worst case allow you to search an entire project for a given term.

Ian Wood
  • 6,515
  • 5
  • 34
  • 73