It's actually very simple and "grep" makes it as easy as possible. I'll outline a few common scenarios and provide some examples.
Say you want to search ALL files within the current directory (and inside/deeper) for the text "phpinfo()"
grep -R "phpinfo()" *
If you want to search only certain files such as only .txt you would do this instead:
grep -R "phpinfo()" *.txt
As you can see this is another very simple but powerful feature of grep to help you find what file contains a certain word/phrase/piece of code etc..