php / html link question

Discussion in 'PHP' started by izlik, May 10, 2009.

  1. #1
    Hello.

    I have a gallery and have a value in $bigger wich comes out as "http://linktoimage.com/imagename.jpg" if you print it "print '$bigger'; and now i want to have that link into a html link and wonder if this is possible or how i could to this otherwise? print '<center><a href="$bigger" target="_blank" >test</a></center>'; just comes out as http://linktoimage.com/$bigger right now :/
     
    izlik, May 10, 2009 IP
  2. aGor

    aGor Member

    Messages:
    80
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    You cant use single quotes when using variables inside the string.

    Use " instead ;)
     
    aGor, May 10, 2009 IP
  3. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #3
    i get a "Parse error: syntax error, unexpected T_STRING" as soon as i try that :/

    print "<center><a href="plogger_get_detail_link();" target="_blank" >Klicka här för större bild</a></center>";
     
    izlik, May 10, 2009 IP
  4. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
    try
    print '<div style="text-align:center;"><a href="$bigger" target="_blank" >test</a></div>';
    Code (markup):
     
    javaongsan, May 10, 2009 IP
  5. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #5
    the output is "http://linktoimage.com/$bigger" wich is wrong :/
     
    izlik, May 10, 2009 IP
  6. mayank@digitalpoint

    mayank@digitalpoint Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    <?php $bigger = trim($bigger,'"') ?>

    print '<div style="text-align:center;"><a href="$bigger" target="_blank" >test</a></div>';
     
    mayank@digitalpoint, May 10, 2009 IP
  7. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #7
    Is $bigger = "http://linktoimage.com/imagename.jpg"?
    Maybe you can put the full code out
     
    javaongsan, May 11, 2009 IP
  8. rehmanasghar

    rehmanasghar Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    hello friends
    tell me the best way how i learn the PHP.or any site where i get the leacture
     
    rehmanasghar, May 11, 2009 IP
  9. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #9
    in another file there is $bigger = plogger_get_detail_link(); and "plogger_get_detail_link()" is what becomes "http://linktoimage.com/imagename.jpg". by just printing $bigger it diplayes the "http://linktoimage.com/imagename.jpg" link without it being a hyperlink ie text only. but i want it to a hyperlink under the text "click here for a larger image" wich is what's not working :/
     
    izlik, May 11, 2009 IP
  10. bird.23

    bird.23 Peon

    Messages:
    13
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    hello

    Try this code:
    print '<a href="$bigger" target="_blank">'.$bigger.'</a>';
     
    bird.23, May 11, 2009 IP
  11. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #11
    or, just turn off PHP parsing before you use the HTML-codes, like this:
    ?>
    <a href="<?php echo $bigger; ?>" target="_blank"><?php echo $bigger; ?></a>
    <?php

    This can easily be used to separate HTML and PHP codes, and avoiding having to continously watch out for the use of " and/or '
     
    PoPSiCLe, May 13, 2009 IP