Php url参数错误

时间:2017-02-23 04:45:08

标签: php

我收到错误。

url.com/test.php?id=123&id2=456

这是我的get.php

<?php

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

?>

我收到第二个参数

的错误

而不是&网址获取&amp;

错误

[23-Feb-2017 03:45:00 UTC] PHP Notice:  Undefined index: id2 in /home/xxxx/public_html/url.com/get.php on line 4

1 个答案:

答案 0 :(得分:1)

  try this..
   url.com/test.php?id=" . urlencode($id) . "&id2=" . urlencode($id2);

 Decode:

  $id= urldecode($_GET['id']);
  $id2= urldecode($_GET['id2']);