Find all files with the extension .php in the current directory and its subdirectories, and replace all occurrences of the word "foo" with the word "bar" in each file.
find ~ -name '*.php' -exec sed -i '' 's/foo/bar/g' {} \;