FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Need to find text in php files





Possum
Hi (Windows 7)

I have a folder with zillions of php files in it. I want to find a page in there that I know a text string is inside that file.

How can I find that file.?

Thank you
Marcuzzo
You could use the built in search option of windows.
it allows you to search for a file name or files that contain your search query.
rjraaz
Possum wrote:
Hi (Windows 7)

I have a folder with zillions of php files in it. I want to find a page in there that I know a text string is inside that file.

How can I find that file.?

Thank you



you can use windows Search with setting as i shown in given picture below.



Uploaded with ImageShack.us

i hope it will resolve your problem
Fire Boar
There's an indispensible utility called grep. Linux users have it out of the box, for Windows you can download and install it. It's a command line utility, so you have to run the dos prompt, but it's very easy to use.

grep 'expression' file1 file2 file3 ...

ex:

Code:
# Simplest usage - find the string "apple" in any file with the .php extension:
grep 'apple' *.php

# Useful addition: search all files in the current directory and all subdirectories:
grep -r 'apple' .

# More advanced usage - find any string where the first non-space characters are // and return it, plus one line of context above and below each match:
grep -n -C 1 '^\s*//' comment.php


The first example is the most common usage - for one word you can drop the quotes and just use grep apple fruit.php. In the second example, -r means "recursive" and the single dot on its own means "current directory". In the third example, -n outputs line numbers, and -C 1 means "with one line of context" (C must be uppercase, lowercase means "count the number of matching lines"). The expression is broken down as: ^ (start of line) \s* (any whitespace) // (the literal // characters).

If you prefer a graphical user interface (it's a bit more bulky but some people run away screaming when presented with a command line tool for some reason) you might look into Windows Grep, which has similar capabilities but requires a lot more clicking. I'd personally recommend the command line grep though - once you've used it once you'll be using it all the time and wondering how you ever managed without it. If you've never used the command line before, all you need to know about is the cd command.
Possum
In XP all you need to do to find a file in a text files is look for a word

In this example I am looking for NOT_AGREE in the WWW directory.



Surely W7 can do this and better?

Thank you..
Nemesis234
i just tried to seach for words in XP, and it doesnt search php files so the inbuilt search function is useless when it comes to php files.
Possum
You're Right..

They are both just text files too.. Whats up with that
Fire Boar
Windows relies far too heavily on extensions: it can't recognize a file based on its contents, the file extension tells all. It doesn't recognize .php as a text file extension, so it ignores it.

Give grep a go. It's much faster than Windows search anyway.
Possum
Greb works well.

I put it on my evacuation computer. Looks very promising.

Thank you.. Smile
toasterintheoven
grep it or find it
FunDa
Possum wrote:
Greb works well.

I put it on my evacuation computer. Looks very promising.

Thank you.. Smile


Grep is awesome. Also learn how to search with "regular expression"


Regex is a pretty neat thing to know. Kind of like knowing kung-fu.
Marcuzzo
FunDa wrote:
Regex is a pretty neat thing to know. Kind of like knowing kung-fu.

Razz

when coding, Regex can be useful, but most of the times it's a pain in the ***.
I try to limit the use of it to a strickt minimum.
but it serves it's purpose for simple tasks, like email validation
Fire Boar
Regular expressions are invaluable! You only need to know a few essentials, and you can look it all up on one of the many regular expression reference web pages. Vanilla grep has a limited regex engine which is good for some purposes, but if you want to have the full complement of regular expressions, run grep with the -E option (grep -E expression file). The essentials are:

[...] - Character class. Matches one of any character within the square brackets. Use - to specify a range of characters.
Example: [A-Za-z] matches one upper or lowercase letter.

[^...] - Negated character class. Identical to character class except it matches anything that's NOT in the brackets.
Example: [^0-9] matches one non-digit character.

(...) - Group. Matches the entire group as it is written. You can add "or" by putting a | character.
Example: (abc|acb|aaa) matches either abc or acb or aaa.

* - Closure. Matches the previous pattern 0 or more times, rather than the usual 1.
Examples: ab* matches one a, then 0 or more bs. (bluh)* matches 0 or more "bluh", so it matches "", "bluh", "bluhbluhbluhbluh", etc. [A-Za-z ]* matches any number of letters or spaces.

? and + - Similar to closure, but different. ? matches 0 or 1 times, + matches 1 or more times.

^ and $ - BOL (Beginning of Line) and EOL (End of Line) respectively. Normally searches are done within each line - you can use BOL and EOL at the beginning or end of the pattern to force the rest of the pattern to only match the beginning part or end part of the line (or both).
Examples: ^#include matches every line that begins with "#include". [^;]$ matches every line that does not end with a semicolon. (Note that the ^ here is in the negated character class, it's not a BOL even though it's the same symbol!) ^Hello$ matches every line that reads exactly "Hello".

Great! Now you too can save the world.
chartcentral
You can install Notepad++ and use its Find in Files option under the Search menu. Smile
Related topics
751 Useful Windows XP Files
Need some php/mysql dlls
add php file to html file
Php - Basic Encryption site
What for <script type="text/php"> is used?
PHP image
tweaking wordpress
How to create a php files that contain a image ?
Reading word documents using PHP?
phpBB - Installation Tutorial
phpbb: check if user is admin
Folder structure and file names - index or name, php or html
Apache
Encodings of Mysql and PHP files have to be same?
Reply to topic    Frihost Forum Index -> Computers -> Operating Systems

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.