Wednesday, June 27, 2012

PHP Search Text In Files (Recursively)

Many times when developers work with someone else's code they run into problems trying to find the location where variable has been initialized because of all "include" and "require" statements. Trying to go through every single time is a hassle and time consuming. Therefore, there has to be an easier way of accomplishing such task without having to pull the hair out of your head thinking "who wrote this non-sense?!?!??!"

After doing a little research online I found a solution to this problem and would like to share it with you guys. It's a little script which takes a the path of the folder where it's located and searches for the query you specify. The script will search inside every file in that folder and then output the results to you.

Here is the link to the file:

The concept is called "recursively searching text in files". The script is easy to you:

(1) Place the file inside the folder where you want to perform the search for text against the files

(2) Run the script in your browser

(3) *The script will automatically determine full path of the folder. You just enter the query and press "Submit" button. The script will perform a search against all your files and print the results on the page below the input fields.

Saving time one script at a time.


No comments:

Post a Comment