How to search a string in a file with specific extension recursively in Linux

If you are in a situation to search for a string inside the content of a specific file with specific extension, you can use the following command:

grep -r –include=”*.php” “text to search” ./


r – is recursive
–include=”*.php” – specifies the file type, in our case it is php
“text to search” – is the string you are searching for.