[英]php add a href with variable
I am trying to make php display the images as links however I cannot make the same images work as links. 我试图使PHP将图像显示为链接,但是我无法使相同的图像作为链接工作。 I want to have the images clickable so they can be opened to their full size.
我想让图像可点击,以便可以将其打开到完整尺寸。
small images: 小图片:
echo '<img src="'.$num.'" width=200 hight = 200 alt="random image">'." ";
I want to make them linked to their full image size, I am trying the below but in vain: 我想让他们链接到他们的完整图像大小,我正在尝试以下但徒劳的:
echo '<a href="'.$num.'"<img src="'.$num.'" width=200 hight = 200 alt="random image">'." ";
Kindly assist 请协助
Your img
tag isn't surrounded by your a
tag properly. 你的
img
标签没有被包围的a
标签正确。 As long as $num
is a valid URL, try 只要
$num
是有效的URL,请尝试
echo '<a href="'.$num.'"><img src="'.$num.'" width="200" height="200" alt="random image"></a> ';
The HTML code you want to obtain: 您要获取的HTML代码:
<a href="***"><img src="***" width="200" height="200" alt="***"></a>
with 与
>
at the end of opening a
, >
在开口的端部a
, </a>
</a>
In PHP: 在PHP中:
echo '<a href="'.$num.'"><img src="'.$num.'" width="200" height="200" alt="***"></a>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.