开发者

Find a hidden PHP function?

So I picked up a job that requires me to fix some broken code that another programmer wrote. It's a mess and is hard to read, but what really gets me is th开发者_Python百科at I need to find a specific function that is buried somewhere in hundreds of php files.

If you were given the function name, say <?php print mystery_function(); ?>, how would one go about tracking this down?

Aside from the brute method of ftping the entire site and having windows search through each file (which I am about to do), is there a way of sending a value to that function and producing an error that is traceable?


$reflection = new ReflectionFunction('mystery_function');
echo $reflection->getFileName();

http://www.php.net/manual/en/class.reflectionfunction.php


If you are on windows you could use wingrep to help you search through the files pretty quickly. As far as a solution in php itself, I'm not sure.


I see NOTHING "brute" in "ftping" the entire site, storing it locally and then running grep for whatever substring,
or even just SSH in and grep on-site.

This let's you find whatever substrings, such as html fragments, filenames and such, not only function names.

Do not call brute a general purpose method used by thousands programmers, you brute ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜