我正试图从我通过电子邮件发送的链接中获得一个唯一的代码。我发送的链接是"website.com/redempt.php?code=xxxxxxxxxx"我正试图捕获x,以便将其与文本文档中的代码列表进行比较。感谢您的帮助。我对php的了解很少。
我唯一知道的尝试:
$code=$_POST['code'];
echo $code;
您要查找的是$_GET
。
$code = $_GET['code'];
echo $code;
阅读材料:
http://php.net/manual/en/reserved.variables.get.phphttp://php.net/manual/en/reserved.variables.post.php
URL使用的查询字符串以$_GET
而非$_POST
的形式传递。试试这个:
$code = $_GET['code'];
echo $code;
URI params在php中作为$_GET
数组提供。尝试$_GET['code']
您也可以使用$_REQUEST
阵列
它被合并为$_POST
、$_GET
和$_COOKIE