PHP embed html image as a link

后端 未结 4 701
执念已碎
执念已碎 2021-01-23 05:50

How do I go about using an image as a link in php? I have never put two html elements together in one echo so it\'s kinda new for me. Here\'s my code:

htmltest.php

相关标签:
4条回答
  • 2021-01-23 06:30

    SIMPLY DO THIS:

    echo '<a href="page.php"><img src="Downloads_clip_image010.jpg" /></a>';
    
    0 讨论(0)
  • 2021-01-23 06:31

    You can also use ' instead of " for strings, e.g.

    This works: echo '"Hello!"'; => "Hello!"

    This wont work: echo "'Hello'";

    0 讨论(0)
  • 2021-01-23 06:32

    For WordPress

    <div class="floatLeft"> 
        <a href="http://trophydevelopers.com">
            <img src="<?php bloginfo('template_url'); ?>/images/powered-by.png">
        </a>
    </div>
    
    0 讨论(0)
  • 2021-01-23 06:41

    Change the line to:

    echo  '<a href="pageone.php"><img src="homelogo.jpg"  /></a>';
    

    OR

    echo  "<a href=\"pageone.php\"><img src=\"homelogo.jpg\"  /></a>";
    

    The problem, as the error somewhat suggests, is that the PHP interpreter can't figure out where your string is supposed to start and end. Using \" escapes the quotes. Using ' around the string gives a unique string delimiter around the string, so you are free to use double quotes inside.

    Note, if you needed both single and double:

    echo  '<a href="pageone.php" title="Andy\'s Link"><img src="homelogo.jpg"  /></a>';
    
    0 讨论(0)
提交回复
热议问题