2

I have spent a long time looking for a way to search a phrase across some of my php files in Windows 7.

Things I have done include:

  • enabling “Always search file names and contents” in Windows Explorer;
  • adding php in the list of “Index properties and File Contents to enable content search” in Indexing Options;
  • making sure the directory is indexed;
  • making sure I have the permission to that directory (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs).

What else should I try? Is that even possible to do that in Windows 7? If not, I’ll have to install Cygwin, which I am reluctant to do now.

cssyphus
  • 37,875
  • 18
  • 96
  • 111
Maria Genko
  • 31
  • 1
  • 2
  • 7
  • Possible duplicate of http://stackoverflow.com/questions/698038/windows-recursive-grep-command-line – user20232359723568423357842364 Jun 19 '13 at 21:12
  • 1
    Did you try this? : http://answers.microsoft.com/en-us/windows/forum/windows_7-files/in-windows-7-i-want-to-search-for-all-files/aadfe1f1-4a33-406b-8e72-bb920efa4f30 – Dany Caissy Jun 19 '13 at 21:13
  • an IDE with a search function, like eclipse is an idea. or a stand alone search application (i use astroGrep and 'search and replace' both windows apps) –  Jun 19 '13 at 21:18

3 Answers3

6

Are you attempting to search the contents of each of the .php files themselves?

Or are you searching for a phrase in filenames with the corresponding .php file extension?

If your goal is the former, the following text editors can easily "Find all in open files" and even "Find all in folder(s)":

If what you're looking for is a command line option, the findstr command should serve you just fine. More information on findstr here.

If you're attempting to do the latter, then the link provided by Dany Caissy looks like it'll have just what you're looking for.

Justice Cassel
  • 359
  • 1
  • 9
  • The method in Dany Caissy's link didn't work for me. The findstr command is exactly what I want. Thanks, everyone, particularly Justice Cassel. – Maria Genko Jun 20 '13 at 01:15
  • notepad++ did the trick (especially since its my editor of choice - no need to install and test) UPVOTED! :) – tony gil Jan 21 '16 at 15:21
0

Linux/Unix has a grep command line utility for doing exactly what you want. If the built-in Win7 search/explorer capabilities don't do what you want, perhaps one of these links for third-party windows equivalents to grep:

Windows-equiv grep command line

Using Windows7 built-in findstr from command line

Note that Justice Cassel's answer has an excellent solution (search in all open files - +1 Justice), if you have your PHP files open in Notepad++. If you aren't using that NP++ for programming, you really should check it out. The FTP plugin (which automatically uploads a file every time you save it) is worth its weight, plus a dump truck, in gold.

Community
  • 1
  • 1
cssyphus
  • 37,875
  • 18
  • 96
  • 111
0

In tools > folder options > search, you need to tick the box for always search file content.

Then when searching for a phrase e.g. "cats and dogs" you need to type the following in the search box

content:(~="cats and dogs").
Sébastien
  • 11,860
  • 11
  • 58
  • 78