将php代码添加到html锚标记 [英] Adding php code to html anchor tag
本文介绍了将php代码添加到html锚标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用定位标记访问已保存在服务器(在上载文件夹中)的上载图像.目的是提供像缩放功能.变焦效果很好,但是图像不显示.
我尝试过这样的事情
I'm trying to access an uploaded image which i've saved on my server (in the uploads folder) using the anchor tag. The aim is the provide like a zoom feature. The zoom works fine but the image doesn't display.
i tried something like this
<?php
//$txt is the actual image name and $image is the name saved in uploads folder,$ext is the extension like .jpg or so.
$image = time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
?>
HTML
//image isn't displayed using
<a href = "<?php echo "uploads/$image" ?>"></a>
但显示是否使用
<a href = "uploads/image.jpg"></a>.
有没有办法我可以使用标记中的php代码访问图像?
is there a way i can access the images with php code in the tag?
推荐答案
您缺少分号,并且$ variable用单引号引起来,因此不会扩展.
You're missing a semi-colon and the $variable is enclosed in single quotes and is therefore not expanded.
<a href="uploads/<?php echo $image; ?>">Image</a>
安东尼.
这篇关于将php代码添加到html锚标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文