简体   繁体   English

php添加带有变量的href

[英]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">'."&nbsp;&nbsp;"; 

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">'."&nbsp;&nbsp;";

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>&nbsp;&nbsp;';

The HTML code you want to obtain: 您要获取的HTML代码:

    <a href="***"><img src="***" width="200" height="200" alt="***"></a>

with

  • a closing > at the end of opening a , 闭合>在开口的端部a
  • an E in height, 高度E
  • no extra spaces around = and =和周围没有多余的空格
  • a closing </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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM