Images and variables

Discussion in 'PHP' started by Handsofmodder, Jul 26, 2008.

  1. #1
    I'm trying to print an image using variables. But all I get is a blank page. here's the code

    <body>
    <?php
    $image='"http://www.simpsoncrazy.com/gallery/images/BartSimpson8.gif"';
    
    print '<html><img src=$image/></html>'
    
    ?>
    </body>
    </html>
    Code (markup):
     
    Handsofmodder, Jul 26, 2008 IP
  2. octalsystems

    octalsystems Well-Known Member

    Messages:
    352
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #2
    Hi it is very simple mistake u r making buddy

    You are trying to expand the value of variable $image placing it inside single quotes
    if u want to expand the value of the variable u should use the double qutes


    so ur code should be


    <body>
    <?php
    $image='"http://www.simpsoncrazy.com/gallery/images/BartSimpson8.gif"';

    print "<html><img src=$image/></html>"

    ?>
    </body>
    </html>



    and it will work for sure


    cheers
     
    octalsystems, Jul 26, 2008 IP
  3. Trusted Writer

    Trusted Writer Banned

    Messages:
    1,370
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    160
    #3
    In addition, you don't need the html tags flanking your image code ("<html><img src=$image/></html>"since you already have a body tag above this statement.
     
    Trusted Writer, Jul 26, 2008 IP
  4. Handsofmodder

    Handsofmodder Peon

    Messages:
    177
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thx, it works now.
     
    Handsofmodder, Jul 27, 2008 IP