php - Globally Replace Old School $PHP_SELF with $SERVER['PHP_SELF'] using sed
Get the solution ↓↓↓Not being an sed expert, I need to replace all instances of the string$PHP_SELF
with$_SERVER['PHP_SELF']
globally in a directory.
This is an "old school" osCommerce application that I need to resurrect temporarily for a showcase.
Answer
Solution:
sed
doesn't recurse on it's own so you'll need to use another tool for that,find
is generally the right answer.
Run this in the top-level directory.sed
will make a backup of each file it reads with a.bak
extension (regardless if it actually does a replacement). If you don't want the backup behavior, use-i
instead of-i.bak
I recommend you first try this on a test directory to make sure it meets expectations.
#!/bin/bash
while IFS= read -r -d $'\0' file; do
sed -i.bak $'s/$PHP_SELF/$_SERVER[\'PHP_SELF\']/g' "$file"
done < <(find . -type f -name "*.php" -print0)
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to undefined function illuminate\encryption\openssl_cipher_iv_length()
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.