echo html

Discussion in 'Programming' started by izlik, Jul 17, 2010.

  1. #1
    why wont it work to echo this image link? :/ it breaks my page.

    <?php

    echo "<a href="http://page.com" target="_blank"><img src="image.jpg" border="0"/></a>";

    ?>
     
    izlik, Jul 17, 2010 IP
  2. KenJackson

    KenJackson Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Don't you have to quote (backslash) the quotes?
    echo "<a href=\"http://page.com/\" target=\"_blank\"><img src=\"image.jpg\" border=\"0\" /></a>";
    Code (markup):
     
    KenJackson, Jul 17, 2010 IP
  3. TheHawk

    TheHawk Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    shoulde be.

    <?php
    
    echo ("<a href="http://page.com" target="_blank"><img src="image.jpg" border="0"/></a>");
    
    ?> 
    Code (markup):
    parenthesis missing.
     
    TheHawk, Jul 17, 2010 IP
  4. simpleloveman

    simpleloveman Guest

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ROFL,


    Things are wrong :p

    Try this and it will Work
    <?php
    echo '<a href="http://page.com" target="_blank"><img src="image.jpg" border="0"/></a>' ;
    ?>

    try this and see it working :)
     
    simpleloveman, Jul 17, 2010 IP
  5. runner

    runner Active Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    yes, u want to add backslash if there r quotes inside a quote
     
    runner, Jul 17, 2010 IP
  6. Ex74

    Ex74 Greenhorn

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #6
    oh god, echoing html is much easier than this...

    <?php
    echo <<<EOF
    <a href="http://page.com" target="_blank"><img src="image.jpg" border="0"/></a>
    EOF;
    ?>
     
    Ex74, Jul 17, 2010 IP
  7. salsan

    salsan Active Member

    Messages:
    190
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #7
    Try this:

    echo '<a href="http://page.com" target="_blank"><img src="image.jpg" border="0"/></a>';


    It should work.
     
    salsan, Jul 18, 2010 IP
  8. khucthuydu

    khucthuydu Member

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #8
    two way : \" or '
    echo \" or echo '
     
    khucthuydu, Jul 18, 2010 IP