PHP - 将图像作为按钮进行回显

时间:2017-10-14 21:02:37

标签: php html5 image

我只是在寻找合适代码的帮助。

我想要什么。

echo "<a target='_blank' href='https://www.wbesite.kom". get_the_title() ."'>" IMAGE HERE "</a>";

此代码不起作用仅仅因为我不了解如何将图像放入"IMAGE HERE"

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:1)

您忘了在.之前和之后添加点IMAGE HERE运算符。

试试这个:

$imagehtml = '<img  src="path/to/image" />'; 
echo "<a target='_blank' href='https://www.wbesite.kom". get_the_title() ."'>". $imagehtml ."</a>";

答案 1 :(得分:0)

我把它放在一起link.也许这对你有用。

<?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>";

?>
相关问题