php 如何使用php从URL获取id

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24396712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:18:05  来源:igfitidea点击:

how to get id from URL using php

php

提问by user3772864

I have this code on my Search page:

我的搜索页面上有此代码:

<a href="detail.php?id=<?php echo $ido;?>"STYLE="TEXT-DECORATION: NONE"><?php echo $nume;?></a>

and i also have a detail.phppage. I need to get the $idovalue from the URL so that I can use it in the detail.phppage to retrieve information from the database.

我也有一个detail.php页面。我需要$ido从 URL获取值,以便我可以在detail.php页面中使用它从数据库中检索信息。

The detail page has a URL like this: detail.php?id=17, I need to get the value after the =, in this case 17, into a variable.

详细信息页面有一个这样的 URL:detail.php?id=17,我需要将 之后的值=(在本例中17)放入一个变量中。

回答by Kinnectus

In your detail.php use: $id = $_GET['id'];you can then use $idaround the rest of your page.

在您的 detail.php use:$id = $_GET['id'];然后您可以$id在页面的其余部分使用。