Log in

View Full Version : Using DD scripts with PHP



akulion
10-31-2006, 02:16 PM
Hi

i often run into the problem that a script on DD would be using both single and double quotes.

As a result using it with PHP becomes very difficult and in parts impossible since I use either echo""; or echo''; and either ways there is a conflict with the single or double quotes in the script itself with the echo statements.

so can someone please teach / guide me on how I can resolve the conflct between the quotes of he echo and script?

Thanks

aku

ItsMeOnly
10-31-2006, 04:26 PM
don't: you can insert PHP into the html without need to care about any (double)quotes- if you do need to generate html content with quotation, using PHP- just escape them, like \" \'

akulion
10-31-2006, 11:04 PM
thanks :D

djr33
11-01-2006, 12:32 AM
Also, you can try not using echoing all together, like this:
<?php
if ($var = "value") { ?>
This html will be displayed<br>
<?php }
else
//you get the idea
?>

Also, there is another way of outputting long chunks of text.
echo <<<OUTPUT
Anything you want can go here " ' " ' etc. etc.
lines and lines of text are fine " and ' won't do anything.
//comments, etc etc won't do anything either, as well as semicolons, and any other symbols.
blah blah
just be sure to end
exactly as you began, but with the starting characters followed by a semicolon.
also, tabs/spaces matter on the last line
like this:
OUTPUT;
?>

ItsMeOnly
11-01-2006, 08:54 AM
Also, you can try not using echoing all together, like this:
<?php
if ($var = "value") { ?>
This html will be displayed<br>
<?php }
else
//you get the idea
?>

Shouldn't this one look like

<?php if ($var == "value") : ?>
This html will be displayed<br>
<?php else : ?>
The other code...
<?php endif ?>

djr33
11-01-2006, 09:36 AM
Nah.
That's the alternate syntax for if statements. You can use it if you want in normal php as well... it has nothing to do with the use of the "?>html<?php" format.
It's not wrong, but just an alternative.
See here:
http://us2.php.net/manual/en/control-structures.alternative-syntax.php

ItsMeOnly
11-01-2006, 01:05 PM
good to know, thanks- never tried the former as I thought it would be illegal syntax (while actually preffering the latter, it's just me- but kinda looks cleaner):)

akulion
11-02-2006, 04:38 PM
hi

so using somthing like this would work yup ?



echo <<<OUTPUT
<a href="javascript:window.open('http://www.something.com/etcetc.html', 'etcetc', 'width=193,height=265');history.go();">Etc Etc</a>
OUTPUT;


I will give it a try.

Thanks again for the detailed explanation :D