Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Jumping PHP versions, need switch of syntax

Status
Not open for further replies.

OmahaVike

Programmer
Joined
Apr 15, 2003
Messages
4
Location
US
Hello all,

I am looking for some help. This isn't exactly a php issue, but rather an ex issue. The long and short of my dilema, is that I'm rolling existing applications across different versions of php.

Anyhow, I've noticed that the statement:

echo ("blah... whatever output");

no longer works. Instead, this will work:

echo "blah... whatever output";

and i have dozens of scripts that have the parenthesis in them, echoing out many different statements. so, i started looking around at replace/substitute commands for recursive file searches and came up with this:

find . -type f -exec ex +g/word1/s//word2/g +wq{} \;

This is all fine and dandy, but I have no way of knowing what is between the quotes (ie what is being echoed), so this won't work. Can anyone help me out with some replacement command that would recursively replace strings like this while leaving the text between the quotes intact?

many many thanks for any help.
 
I'd write up a little perl script (or go ahead an use PHP) which just opens each file, and does a regex replace, then rewrites the file.

something like

preg_replace("echo (\([.]*\));", "echo $1;", $file);

should do it... (I might be mixing in emacs syntax in which case you'll need some small adjustments.

-Rob

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top