[英]PHP - Echo an image as button
我只是在寻找编写正确代码的帮助。
我想要的是。
echo "<a target='_blank' href='https://www.wbesite.kom". get_the_title() ."'>" IMAGE HERE "</a>";
这段代码不能正常工作,因为我不明白如何将图像放入"IMAGE HERE"
。
有人可以帮忙吗?
你忘记加点了.
操作员在您的IMAGE HERE
之前和之后。
尝试这个 :
$imagehtml = '<img src="path/to/image" />';
echo "<a target='_blank' href='https://www.wbesite.kom". get_the_title() ."'>". $imagehtml ."</a>";
<?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.