簡體   English   中英

從 URL 獲取 ID,保存到變量中並在 href 中使用,全部使用 PHP

[英]Get ID from URL, save it into variable and use in href, all using PHP

簡而言之,我想從 URL 中獲取 ID,將其保存到變量中並在通過img標簽打開的 href 鏈接中表示它,所有這些都使用 PHP。

我的 URL 是:test.php?id=123

我想將 ID 保存到 href 中使用的變量ticket_dym_id中。

我的代碼:

<?php

$id = $_GET['id'];
$ticket_dym_id = $id;

<html>
  <title>title</title>
</html>
<center>
<a href="test2?id=&lt;$ticket_dym_id&gt;"><img="img.jpg"/></a>

</center>
?>

您可以使用 php echo

<?php
$id = $_GET['id'];
$ticket_dym_id = $id;
?>

<html>
  <title>title</title>
</html>
<center>
  <a href="test2?id=<?php echo $ticket_dym_id; ?>">
</center>

回聲文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM