My code is littered with things like this
Write (thePhpFile, ' echo "<option value=\"' +
theControl.Name +
'_selection\">" . $' +
theControl.Name +
'_values[$_POST["' +
theControl.Name +
'_selection"]];');
which genrates the following PHP code
echo "<option value=\"ComboBox1_selection\">" .
$ComboBox1_values[$_POST["ComboBox1_selection"]];?>
Surely there's a better way to handle this? Maybe a Delphi function which I can pass the desired PHP string and have it double up quotes where necessary? Or am I deluding myself?
The basic algorithm would seem to be
// assume all PHP strings are double quoted, even when it's inefficient
find the first double quote, if any
find the last double quote, if any
for every double quote in between
change it to \""
Does that sound right? Maybe I should code it myself?
Hmmm, not so easy ... in the snippet above, we wouldn't want to escape $_POST["ComboBox1_selection"]
- better just to hand code the mess shown at the top?
Any ideas? I'm off now to google "generating php from delphi" - which is probably what I should have done weeks ago :-/