![](/img/trans.png)
[英]PHP,CakePHP,HTML: The anchor tag is appended inside a code tag, how can seperate this anchor tag?
[英]Adding php code to html anchor tag
我正在嘗試使用錨標記訪問我已保存在我的服務器(在uploads文件夾中)的上傳圖像。 目的是提供像縮放功能。 縮放工作正常,但圖像不顯示。 我試過這樣的事情
<?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代碼訪問圖像?
你沒有關閉<?PHP
標簽。 這樣做
<a href = "<?php echo 'uploads/$image'; ?>"></a>
您缺少一個分號,$變量用單引號括起來,因此不會展開。
<a href="uploads/<?php echo $image; ?>">Image</a>
安東尼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.