How can i onvert this simple html line to a php line

Discussion in 'PHP' started by ASTRAPI, May 5, 2010.

  1. #1
    Hello

    How can i onvert this simple html line to a php line:

    <div style="text-align:center"><a href="http://www.site.com"><img src="blah.png" alt="" height="100" width="100" /></a></div>
    HTML:
    Thank you
     
    ASTRAPI, May 5, 2010 IP
  2. Lam3r

    Lam3r Active Member

    Messages:
    235
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    What do you mean by convert it? If you want the same thing just in PHP I guess just do this:
    
    <?php echo "<div style=\"text-align:center\"><a href=\"http://www.site.com\"><img src=\"blah.png\" alt=\"\" height=\"100\" width=\"100\" /></a></div>";?>
    
    PHP:
    If that's not what you wanted you need to give more details on what you actually need, VERY general.
     
    Lam3r, May 5, 2010 IP
  3. ASTRAPI

    ASTRAPI Guest

    Messages:
    500
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok thanks :)
     
    ASTRAPI, May 5, 2010 IP
  4. Wtfuxbbq

    Wtfuxbbq Peon

    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4

    It's much better to use single quotes for literal strings; you don't have to escape every double quote and it executes slightly faster.

    
    <?php echo '<div style="text-align:center"><a href="http://www.site.com"><img src="blah.png" alt="" height="100" width="100" /></a></div>'; ?>
    
    PHP:
     
    Wtfuxbbq, May 5, 2010 IP
  5. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    or you can use HEREDOC (i think i got the name right!):

    <?php
    
    echo <<<HTML
    <div style="text-align:center"><a href="http://www.site.com"><img src="blah.png" alt="" height="100" width="100" /></a></div>
    HTML;
    
    ?>
    
    PHP:
    and you don't even have to worry about use of single/double quotes. you can even echo php, i.e. variables et al, directly within it .
     
    szalinski, May 7, 2010 IP