An innocent joke on Facebook brought in something really golden – Stack Overflow Buddy. It is a fun PHP library for all those of you who search for code examples on Stack Overflow and then copy-paste those into your projects.
Wow, how’s it work?
If you’re impressed, you should probably stop reading here.
- Split the camelCased function call into words
- Grab the top scoring PHP tagged questions with those words in the title from StackOverflow’s API
- Grab the top scoring answers for those questions
- Pull any and all code blocks from those answers
- Find the first code block that:
- Inteprets without error
- Contains one or more functions
- One of the functions has the same amount of arguments as were passed by the user
- Then we throw caution to the wind, eval, and call the new method!
This is absolutely brilliant!