如何读取 PHP 和 HTML 中的查询字符串?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4153218/
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 12:07:43  来源:igfitidea点击:

How to read the query string in PHP and HTML?

phphtmlquery-string

提问by Ahmad Farid

a URL ending with something like portal.php?key2=hellohow can I get the value of "key2"?

以诸如portal.php?key2=hello如何获取“key2”的值之类的内容结尾的 URL ?

回答by Gav

$_GET['key2']

will get you the value from a query string.

将从查询字符串中获取值。

$_POST['key2']

will get you the value from a form posted.

将从张贴的表格中获取价值。

$_REQUEST['key2']

will get you either of the above if it exists.

如果存在,将为您提供上述任何一项。

回答by meder omuraliev

var_dump( $_GET['key2'] );

回答by johannes

GET data is decoded into the $_GET super-global array. See http://php.net/manual/en/language.variables.external.php

GET 数据被解码到 $_GET 超全局数组中。见http://php.net/manual/en/language.variables.external.php