通过 URL 在页面中传递变量 [英] Passing variable in pages through URL

查看:36
本文介绍了通过 URL 在页面中传递变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有两个代码,一个工作正常,而其他人无法解释第二个代码有什么问题.

Here are two codes one works fine while other doesn't can anyone explain me what is wrong with second code.

$Id = $row['id'];
<a href="page2.php?Id=<?php echo $row['id'] ?>">Product></a>

上面的代码工作正常.但下面的代码没有.在第二页,我使用了 get 方法.

The code above works fine. But the code below doesn't. On page two I am using get method.

<a href="page2.php?Id=$Id">Product></a>

推荐答案

你不能 print php 变量没有 echo 或 php 标签

You not print php variable without echo or php tag

<a href="page2.php?Id=<?php echo $Id; ?>">Product></a>

所以改变这个:-

href="page2.php?Id=$Id"

对此:-

href="page2.php?Id=<?php echo $Id; ?>"

这篇关于通过 URL 在页面中传递变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆