Results 1 to 8 of 8

Thread: Using DD scripts with PHP

  1. #1
    Join Date
    Jun 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Using DD scripts with PHP

    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

  2. #2
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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 \" \'

  3. #3
    Join Date
    Jun 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Also, you can try not using echoing all together, like this:
    PHP Code:
    <?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.
    PHP Code:
    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;
    ?> 
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33
    Also, you can try not using echoing all together, like this:
    PHP Code:
    <?php
    if ($var "value") { ?>
    This html will be displayed<br>
    <?php }
    else
    //you get the idea
    ?>
    Shouldn't this one look like
    PHP Code:
    <?php if ($var == "value") : ?>
    This html will be displayed<br>
    <?php else : ?>
    The other code...
    <?php endif ?>

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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...ive-syntax.php
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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)

  8. #8
    Join Date
    Jun 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hi

    so using somthing like this would work yup ?

    Code:
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •