grep is the GNU Regular Expressions Program. It's fine for searching for lines, but not for replacing or modifying.
The program your after is sed. A small script like:
for file in $(find -type f -iname '*.php')
cp "$file" "$(dirname "$file")/$(basename "$file" .php).bak"
cat "$file" | sed 's%old%new%' > "$(dirname "$file")/$(basename "$file" .php).new
mv -f "$(dirname "$file")/$(basename "$file" .php).new" "$file"
echo "done "$file
where 's%old%new%' is a regular expression for substitution.
I haven't tried this code - just written it here, but it should pretty much work. It'll also create a backup file (i.e. ./path/to/file.php is copied to ./path/to/file.bak). Also, sed can't read a file and have the console write to it as well. Causes all sorts of problems, so you need to redirect the output to another file and then mv the file back.