Getting by magicquotes that pop up in PHP scripts

58 Views Asked by At

My style of programming requires the use of Word, and magic quotes cannot be turned off on the machine I work on without breaking other Word utilities I use. I need a way to clear magic quotes automatically and, if possible, remotely from a PHP script, using PHP, Perl or JavaScript.

I will often have a thousand or more statements running at once; on one script. If only one magic quote has worked its way through, I must identify the error by trial and error (they're impossible to see), that is by going to an identical magic quote (left or right) and copy-pasting it to the replace utility in Wordpad, where I've pasted my scripting, and then hitting replace.

If this happens forty times in a day (maximum), I might lose an hour or two doing this stupid task.

1

There are 1 best solutions below

0
John On

This is the kind of script I would like to adapt to my problem; instead of deleting lines with a 0 in front and writing the output to a new file, it would write changed content to a new file with curlyquotes changed to straight quotes.

?>php
$file = file("text.php");
$newLines = array();
foreach ($file as $line)
if (preg_match("/^(-\d+|0)/", $line) ===0)
$newLines[] = chop($line);
$newFile = implode("\n", $newLines);
file_put_contents("demo2.txt", $newFile);
<?