[英]PHP - Echo an image as button
I'm just looking for little help to make the right code.我只是在寻找编写正确代码的帮助。
What i want.我想要的是。
echo "<a target='_blank' href='https://www.wbesite.kom". get_the_title() ."'>" IMAGE HERE "</a>";
This code doesn't work simply because I don't understand how to put image in "IMAGE HERE"
.这段代码不能正常工作,因为我不明白如何将图像放入"IMAGE HERE"
。
Can someone help?有人可以帮忙吗?
You forgot to add the dot .
你忘记加点了.
operator before and after your IMAGE HERE
.操作员在您的IMAGE HERE
之前和之后。
Try this :尝试这个 :
$imagehtml = '<img src="path/to/image" />';
echo "<a target='_blank' href='https://www.wbesite.kom". get_the_title() ."'>". $imagehtml ."</a>";
I put this together from this link.我从这个链接把它放在一起。 Perhaps it will work for you.也许它对你有用。
<?php
function get_the_title() {
echo "result of the get_the_title()";
}
// A few settings
$img_file = 'http://www.abarrak.com/public/icons/stackoverflow-icon.png';
// Read image path, convert to base64 encoding
$imgData = base64_encode(file_get_contents($img_file));
// Format the image SRC: data:{mime};base64,{data};
$src = 'data: '. $img_file .';base64,'.$imgData;
// Echo out a sample image
$img = '<img src="'.$src.'">';
echo "<a target='_blank' href='https://www.wbesite.kom". get_the_title()
."'>" . $img . "</a>";
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.